Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I write to the console from a Laravel Controller?

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.

like image 236
Jrop Avatar asked Aug 05 '14 21:08

Jrop


People also ask

How do you call artisan command in Laravel controller?

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.

How do you call a controller in Laravel?

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.

What is DD () in Laravel?

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.


1 Answers

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

like image 196
Jrop Avatar answered Oct 07 '22 01:10

Jrop