So I have a Laravel controller:
class YeahMyController extends BaseController { public function getSomething() { Console::info('mymessage'); // <-- what do I put here? return 'yeahoutputthistotheresponse'; } }
Currently, I'm running the application using artisan (which runs PHP's built-in development web server under the hood):
php artisan serve
I would like to log console messages to the STDOUT
pipe for the artisan process.
So we can do it by using Artisan facade. In Laravel Artisan facade that way we can easily run the all artisan command also with argument. So Artisan facade have two method one call() and another one is queue() through we can simply make process in call like seeder and also migration run etc.
use App\Http\Controllers\UserController; Route::get('/user/{id}', [UserController::class, 'show']); When an incoming request matches the specified route URI, the show method on the App\Http\Controllers\UserController class will be invoked and the route parameters will be passed to the method.
dd stands for "Dump and Die." Laravel's dd() function can be defined as a helper function, which is used to dump a variable's contents to the browser and prevent the further script execution.
Aha!
This can be done with the following PHP function:
error_log('Some message here.');
Found the answer here: Print something in PHP built-in web server
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With