在生产环境中部署 Laravel 涉及一系列优化命令(缓存 config/routes/views)、安全配置、运行适当的 web 服务器堆栈以及管理队列和调度程序。Laravel 提供特定的 Artisan 命令来优化生产环境。
生产环境优化命令
# cache config, routes, and views → significant speedup (skip recompilation per request)
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache
php artisan optimize
composer install --optimize-autoloader --no-dev
