Home

Awesome

Running a Laravel application

theories

list features -> orgranize them into categories, see GH issue!

ErrorDocument 500 /errors/HTTP_INTERNAL_SERVER_ERROR.html ErrorDocument 503 /errors/HTTP_SERVICE_UNAVAILABLE.html https://templates.mailchimp.com/resources/inline-css/

mysqldump --routines --triggers --events

Setting up GitHub repository

Entry points

Startup methods.

  1. Web - through public/index.php
  2. CLI - through artisan
  3. Queue workers - through artisan queue:work
  4. Cron job - through artisan schedule:run

Security

Security Exceptions

protected $securityExceptions = [
        \Illuminate\Session\TokenMismatchException::class,
        \Illuminate\Validation\ValidationException::class,
        \Illuminate\Auth\Access\AuthorizationException::class,
        \Illuminate\Database\Eloquent\ModelNotFoundException::class,
        \Symfony\Component\HttpKernel\Exception\HttpException::class,
        \Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class,
];

Caches

Use Redis PECL extension instead of Predis, and the key hash tag.

See /vendor/laravel/framework/src/Illuminate/Foundation/Application.php

Caching depends on APP_ENV variable.

Static analysis

Throttle 404 errors

routes/web.php

use Illuminate\Support\Facades\Route;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

// Throttle 404 errors
Route::fallback(static function () {
    throw new NotFoundHttpException();
})->middleware('throttle:10,1');

Is Laravel down?

  1. ./artisan tinker --execute='printf("Application is %s.",App::isDownForMaintenance()?"down":"up");'
  2. ls storage/framework/down
  3. ./artisan isdown - using Commands/IsDownForMaintenance.php

Check route methods

./artisan route:check - using Commands/RouteCheckCommand.php

Check PHP version after PHP upgrade

Insert this line in the top of bootstrap/app.php

if (phpversion() !== '8.2.7') dd('Different PHP version:', phpversion());

Check all four entry points!

Debugging

https://github.com/spatie/ray

Add the following to app/Providers/AppServiceProvider.php

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

    public function boot(): void
    {
        DB::listen(static function ($query) {
            Log::info('SQL query', [$query->sql, $query->bindings, $query->time]);
        });
    }

URL categories

Nova

Custom exception handling https://nova.laravel.com/docs/4.0/installation.html#error-reporting