php Laravel 部署...有标准的方法吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20383871/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:08:15  来源:igfitidea点击:

Laravel deployment... there is a standard way?

phpdeploymentlaravelweb-deployment

提问by James

I'm starting to use Laravel 4 seriously in my projects. I understand that this framework offers many advantages when developing RESTful applications. But I understand that there is no consensus about how do deployment / publishing and app using Laravel. I am still using FTP to transfer files to my Production host. But my question is, Is there any standard way to do the same but from Laravel? I am faithful believing that with a little ingenuity one can create something like php artisan publish [Production server name and SSH credentials]as parameters.

我开始在我的项目中认真地使用 Laravel 4。我知道这个框架在开发 RESTful 应用程序时提供了许多优势。但据我所知,关于如何使用 Laravel 进行部署/发布和应用程序并没有达成共识。我仍在使用 FTP 将文件传输到我的生产主机。但我的问题是,除了 Laravel 之外,是否有任何标准的方法可以做到这一点?我坚信,只要稍加创意,就可以创建类似php artisan publish [生产服务器名称和 SSH 凭据]作为参数的东西。

I have read something interesting from Anahkiasen/rocketeerand Christopher Pitt, both great sources but there is a consensus or standard way to publish applications using laravel?

我从Anahkiasen/rocketeerChristopher Pitt那里读到了一些有趣的东西,这两个都是很好的来源,但是否有使用 laravel 发布应用程序的共识或标准方法?

采纳答案by Antonio Carlos Ribeiro

This is not really a Laravel problem/question, you have to ask on a dev-ops forum what they would do to deploy a PHP application like yours.

这不是真正的 Laravel 问题/问题,您必须在开发运营论坛上询问他们将如何部署像您这样的 PHP 应用程序。

Your Laravel application is basically PHP application, some packages are provided by Composer, so it's more a Composer application than a Laravel one, but you might have some Laravel needs, like executing php artisan migrate, or any other artisan command to post-deploy your application, or not, so, it's more a requirement of your application than Laravel, right?

你的 Laravel 应用程序基本上是 PHP 应用程序,一些包是由 Composer 提供的,所以它更像是一个 Composer 应用程序而不是 Laravel 应用程序,但你可能有一些 Laravel 需求,比如执行php artisan migrate,或任何其他工匠命令来部署你的应用程序,或者不是,所以,它比 Laravel 更需要你的应用程序,对吧?

I developed a package to do my deployments, Deeployer. The intent of this package is, everytime I push my application to the production (or staging) branch, Github will fire a hook that tells my server to do whatever it needs to deploy my application to my own VPS. In a basic deployment it will:

我开发了一个包来进行部署,Deeployer。这个包的目的是,每次我将我的应用程序推送到生产(或暂存)分支时,Github 都会触发一个钩子,告诉我的服务器做任何需要将我的应用程序部署到我自己的 VPS 的事情。在基本部署中,它将:

1) git pullthe repository

1)git pull存储库

2) Execute composer updateto update my vendor folder

2)执行composer update更新我的供应商文件夹

3) Execute bower updateto download whatever js or css I've installed

3)执行bower update下载我安装的任何js或css

4) Execute php artisan migrateto upgrade my database schema

4)执行php artisan migrate升级我的数据库架构

5) Execute chmodand chownto fix whatever permission mess those commands might have made to my directories while downloading files

5)执行chmodchown修复下载文件时这些命令可能对我的目录造成的任何权限混乱

See? Those are things that are very particular to my deployment structure, that's why I don't really think you are going to find consensus about a deployment app. When Anahkiasen first build Rocketeer, someone shout: "Why are you doing this if we already have Capistrano?".

看?这些是我的部署结构非常特殊的事情,这就是为什么我真的认为您不会就部署应用程序达成共识。当 Anahkiasen 第一次构建 Rocketeer 时,有人喊道:“如果我们已经有了 Capistrano,你为什么要这样做?”。

Yesterday I bumped into this one: http://www.deployhq.com/packages, used by Ben Corletfrom Cartalyst and other nice guys.

昨天我遇到了这个:http: //www.deployhq.com/packages,由CartalystBenCorlet 和其他好人使用。

There's also Rocketeer: http://rocketeer.autopergamene.eu/.

还有 Rocketeer:http://rocketeer.autopergamene.eu/ 。

Don't forget that Laravel itself has it's own SSH Remote component (I used it on Deeployer and Rocketeer uses it too), that might help you do whatever you need to deploy your app.

不要忘记 Laravel 本身有它自己的 SSH 远程组件(我在 Deeployer 上使用它,Rocketeer 也使用它),这可能会帮助您执行部署应用程序所需的任何操作。

So, you better think what are your deployment needs and find your way, using a package, app or just Laravel.

因此,您最好考虑一下您的部署需求并找到适合自己的方式,使用包、应用程序或仅使用 Laravel。

回答by Anton Medvedev

There are a lot of deployment tool, like Capistrano. I recommend you to take a look at Deployer: it's has simple api, bundled with recipes for popular frameworks and apps, and can do 100% parallel task execution. Also it requires only for PHP.

有很多部署工具,比如 Capistrano。我建议你看看 Deployer:它有简单的 api,捆绑了流行框架和应用程序的配方,并且可以 100% 并行执行任务。它也只需要 PHP。

Here is an example of simple task:

下面是一个简单任务的例子:

task('my_task', function () {
    // Your tasks code...
});

Also it has a good quality code:

它还有一个高质量的代码:

Code QualityCode ClimateCode Coverage

代码质量代码气候代码覆盖率

Deployer

部署者

回答by fl3x7

You may want to check out Rocketeer: http://rocketeer.autopergamene.eu/

您可能想查看Rocketeerhttp: //rocketeer.autopergamene.eu/

回答by reikyoushin

If you are asking for a standard, I don't think there is one. But an alternative from FTP, well, have you considered using git as a way to deploy your site to production?

Here is how you do it: http://danbarber.me/using-git-for-deployment/(Link is broken) https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps

如果你要求一个标准,我认为没有。但是 FTP 的替代方案,您是否考虑过使用 git 作为将站点部署到生产环境的一种方式?

这是您的操作方法:http: //danbarber.me/using-git-for-deployment/(链接已断开) https://www.digitalocean.com/community/tutorials/how-to-set-up-自动部署与 git-with-a-vps

Basically the summary is that you have a bare git repository, your own local repositoryand your production repository.. now by configuring the correct hooks, when you push to the bare git repository, a hook in it will tell the production repository to pull the most recent changes you commited down to the production. And in addition, setting up the correct credentials in your config depending on the environment.. you can create a new folder ex. app/config/productionand app/config/stageso that you can easily run the application even while switching on both servers..

基本上总结是你有一个bare git repository,你自己的local repository和你的production repository.. 现在通过配置正确的钩子,当你推送到 时bare git repository,它中的一个钩子会告诉生产存储库拉取你提交到生产的最新更改。此外,根据环境在您的配置中设置正确的凭据..您可以创建一个新文件夹ex。app/config/production并且app/config/stage,这样就可以轻松运行甚至在两台服务器上切换应用..

回答by dericcain

I'm not so sure about a standard way either. You do have Forgeand Envoyerthat work with Laravel, so that is something to look into.

我也不太确定标准方式。你确实有与Laravel 一起工作的ForgeEnvoyer,所以这是值得研究的。

Here is a way to deploy Laravel using Rocketeer and Git. It is very easy to setup and allows you to use multiple servers (think staging, production, etc.)

这是一种使用 Rocketeer 和 Git 部署 Laravel 的方法。它非常容易设置并允许您使用多个服务器(想想登台、生产等)

http://dericcain.com/blog/deploying-laravel-5-with-rocketeer

http://dericcain.com/blog/deploying-laravel-5-with-rocketeer