Print Instead Of Logger (ARCH7157)
هذا المحتوى غير متوفر بلغتك بعد.
Key php.logging.echo-instead-of-logger · Severity info · Category logging
Using echo, print, or var_dump for diagnostics instead of the framework logger makes output impossible to configure, level, or aggregate.
Incorrect
Section titled “Incorrect”<?phppublic function handle(Request $request): void{ echo 'Processing request ' . $request->getId(); var_dump($request->all());}Correct
Section titled “Correct”<?phppublic function handle(Request $request): void{ $this->logger->info('Processing request', ['id' => $request->getId()]);}Log through a PSR-3 logger at the appropriate level instead of writing to stdout.