Saturday, March 17, 2018

Laravel - Setup Tips


Valet

HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers:
To resolve this error, do the following:
1. valet stop
2. valet uninstall
3. rm -rf ~/.valet
4. valet install
5. valet start
6. Link the applications again.


Restart phpfpm on homestead:
sudo nginx -s reload
sudo service php7.0-fpm restart

Laravel - Code Tips

To Log all queries executed by Eloquent:
Add the below code snippet into AppServiceProvider boot() method.

\Event::listen('Illuminate\Database\Events\QueryExecuted', function ($query) {
            \Illuminate\Support\Facades\Log::info($query->sql);
            \Illuminate\Support\Facades\Log::info($query->bindings);
            \Illuminate\Support\Facades\Log::info($query->time);
        });

\DB::listen(function($sql, $bindings, $time) {
            Log::info($sql);
            Log::info($bindings);
            Log::info($time);
        });