Laravel工匠优化最佳实践 [英] Laravel artisan optimize Best Practices
问题描述
我试图完全了解Laravel(5.1) artisanoptimize --force
时修改或创建了哪些文件.目标是不要在生产中炸毁该应用程序!运行命令后,我看到以下文件已被修改:
I'm trying to fully understand the Laravel (5.1) artisan optimize
command and best practices, but the documentation seems lacking. I don't have Composer installed on the production server so, specifically, I want to know what files are modified or created when running artisan optimize --force
on development that must get pushed to production. The goal being not to blow up the app in production! After running the command, I see the following files have been modified:
\bootstrap\cache\compiled.php
\vendor\composer\ - the entire directory
\vendor\autoload.php
我是不是想得太多,还是只是将这些文件推送到生产环境中,我就很好了吗?此外,关于何时运行
Am I overthinking this, or do I just push these files to production and I'm good to go? Also, what is the best practice regarding when to run artisan optimize
? Each time a new model is created? What about controllers, routes and helper classes?
最后,我看到 \ bootstrap \ cache \ compiled.php
文件的大小高达548KB,几乎是17,000行!真的认为这是最佳选择吗?
Lastly, I see the \bootstrap\cache\compiled.php
file is a whopping 548KB and almost 17K lines! Is that really considered optimal?
推荐答案
Laravel的常规做法是在生产服务器上安装作曲器.
Normal Laravel practice is to have composer installed on your production server.
以下是 Envoyer (由Laravel的创建者制作)用于在生产环境中部署应用程序的步骤-我已注释了他们在下面:
These are the steps Envoyer (made by Laravel's creator) takes to deploy an app on production -- I've annotated them below:
# Install application dependencies, such as the Laravel framework itself.
#
# If you run composer update in development and commit the `composer.lock`
# file to your repository, then `composer install` will install the exact
# same versions in production.
composer install --no-interaction
# Clear the old boostrap/cache/compiled.php
php artisan clear-compiled
# Recreate boostrap/cache/compiled.php
php artisan optimize
# Migrate any database changes
php artisan migrate
这篇关于Laravel工匠优化最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!