Laravel工匠优化最佳实践 [英] Laravel artisan optimize Best Practices

查看:69
本文介绍了Laravel工匠优化最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图完全了解Laravel(5.1) anisanoptimize 命令和最佳做法,但似乎缺少该文档.我没有在生产服务器上安装Composer,因此,特别是,我想知道在必须推送到生产的开发环境中运行 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

我是不是想得太多,还是只是将这些文件推送到生产环境中,我就很好了吗?此外,关于何时运行 artisan优化的最佳实践是什么?每次创建新模型?控制器,路线和助手类呢?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆