در حال بارگذاری ...

Overview of Deployment0:01

In order to fully understand the value Forge is providing for us, let's take a look at what it looks like to deploy a modern Laravel application. So in general, everything that comprises our application is gonna live and get other than certain pieces of our application that differ from environment to environment. What I mean by that is if the app is the same on six different installs, your local staging and maybe three different production installations,

Environment-Specific Files0:22

different installs, your local staging and maybe three different production installations, except in these particular ways, those particular ways are ideally not gonna be in Git. And sometimes they are occasionally, but most of the time they're gonna live in files like for example, the ENV file, which is automatically get ignored. And what happens to the ENV file is we have a whole bunch of configuration items, as you can see here,

And what happens to the ENV file is we have a whole bunch of configuration items, as you can see here, we've got things like the URL, we've got things like the log configurations, the database configurations, and the session configurations. Those are definitely gonna be different because you don't have the same database username and password on dev staging and production. So those need to be extracted out from gi. We don't want them to find in our GI committed

What Git Ignores0:56

So those need to be extracted out from gi. We don't want them to find in our GI committed code that's also less safe. That way we can take a look at the Git ignore file to see some other files that are ignored on an install by install basis. We've got logs, we've got the environment files, we've got some application specific files like you know, PHP actor and PHP unit, and all these. We've got our dependencies.

PHP actor and PHP unit, and all these. We've got our dependencies. Even though those dependencies are probably gonna be the same on an install by install basis, we don't want to have to commit them. And sometimes the installer actually changes how those dependencies are parsed based on the environment of that particular application. We've got the built files because again, usually we're gonna freshly build tools, uh,

We've got the built files because again, usually we're gonna freshly build tools, uh, or build our application using NPM. Uh, and then we've also got some storage files, for example, user uploads. And then we've got the composer dependencies and some more configuration. So these are by default, the files that will not be the same on one instance of your application versus the other.

Branch-Based Deploy Triggers1:48

that will not be the same on one instance of your application versus the other. And they don't live in Git. Everything else lives in Git. Now in Git you do have things like branches, and by default we're gonna have this main branch. And the main branch is what we assume is gonna be deployed to our production application most of the time. And so what happens is we set up some online tooling. It will be forged soon, but prior to Forge we did the same thing

Deploy Script Steps2:09

It will be forged soon, but prior to Forge we did the same thing that says every single time a new commit goes to Maine, run a particular set of steps, run a a deploy script. And so this is just a sample deploy script. This is not shipped with Laravel on anything. I just want to kind of show you what in general these deploy scripts do. They go into the production directory that's being served by your web server.

They go into the production directory that's being served by your web server. They pull down the latest code and then they install dependencies and they run build tool build tools, basically. So it's usually composer install PHP r doesn in migrate, maybe clear a cache or something else. And then you do NPM install and you'd run whatever tooling you need for NPM to build your front end.

and you'd run whatever tooling you need for NPM to build your front end. And that's really it. That's the basis of deploying these modern Laravel applications.

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟