Awesome
Running a Laravel application
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
- See GitHub repository inspection
- The first commit must be a tagged release of
laravel/laravel
Entry points
Startup methods.
- Web - through
public/index.php
- CLI - through
artisan
- Queue workers - through
artisan queue:work
- Cron job - through
artisan schedule:run
Security
- HTTP method not in routes
- HTTP 404
- CSRF token mismatch (Google Translate, Facebook app, Google Search "Cached")
- Failed login attempts
- Requests for .php files
- Non-empty hidden field in forms
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.
- Compiled classes
/bootstrap/cache/compiled.php
removed in 5.4 - Services
/bootstrap/cache/services.php
- flushed in composer scriptpost-autoload-dump
- Discovered packages
/bootstrap/cache/packages.php
- flushed in composer scriptpost-autoload-dump
- Configuration cache
/bootstrap/cache/config.php
- flushed byartisan config:clear
- Routes cache
/bootstrap/cache/routes.php
- flushed byartisan route:clear
- Events cache
/bootstrap/cache/events.php
- flushed byartisan event:clear
- Application cache (
CACHE_DRIVER
) - flushed byartisan cache:clear
- Blade templates cache
/storage/framework/views/*.php
- flushed byartisan view:clear
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?
./artisan tinker --execute='printf("Application is %s.",App::isDownForMaintenance()?"down":"up");'
ls storage/framework/down
./artisan isdown
- usingCommands/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
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
- Root files - stored in
public/
andpublic/.well-known/
directories - Static assets - stored in various subdirectories of
public/
- User generated media - stored in
storage/app/public/
directory - Virtual URL-s are handled by Laravel started in
public/index.php
- Explicit API calls prefixed with
/api/
in URL path
Nova
Custom exception handling https://nova.laravel.com/docs/4.0/installation.html#error-reporting