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

Envoyer Environment Management0:00

Hi, this is Taylor Rotwell, and in this screencast, I'd like to talk about environment management with Envoyer. Now, if you have multiple servers, managing your environment file, which in Laravel 5 is your .env file, can be pretty cumbersome. You have to SSH into each server and update the file and add new variables. However, in Envoyer, we make this a lot easier for you. Let me show you. If I scroll down to the servers tab, I can see this Manage Environment button. This lets me manage the environment file across all of my servers, or at least all the servers I want to put an environment file on. How it works is, we want to keep this secure. When you first come into Envoyer and set up your environment, it will ask you for an environment key. This will be used to encrypt all your environment information that is stored on the server. We do not store this key at all. Each time you

Encrypting with Environment Key0:42

it will ask you for an environment key. This will be used to encrypt all your environment information that is stored on the server. We do not store this key at all. Each time you modify your environment, you will have to re-enter the key so that we can decrypt your environment information. This is very nice because it basically makes it totally not feasible for us to decrypt your environment information without you providing this key, and we never store your environment information unencrypted. All right, so I'm going to go ahead and enter an environment key here and unlock the environment. Now we can enter any contents into this file we like, so let's go ahead and put a few variables in there. All right, so we've got a couple of environment variables here. Now we can select the servers that we want to sync this environment file to. I'll just select both servers because we want

Syncing .env to Servers1:28

All right, so we've got a couple of environment variables here. Now we can select the servers that we want to sync this .env file to. I'll just select both servers because we want to put this .env file on both of our production servers, and we can just hit Update here. Right here, we should see a Syncing to Environment status, which will let us know that the .env file is being pushed up to the server, and you can see both of those synced up pretty quickly. So let's actually look on our server and we can see what's actually out there. All right, I'm SSHed into the server. Let's go into the default directory, and there, of course, is my current symlink. Now if I show all the files, you can see that the .env file is present, and I can just take a look at that, and you can see there's the environment variables that we put into Envoyor, so it did sync out to the server. Now let me show you

Deployments Preserve Environment2:07

file is present, and I can just take a look at that, and you can see there's the environment variables that we put into Envoyor, so it did sync out to the server. Now let me show you something really cool. When I actually deploy my project, let me start a fresh deployment. Remember, this is a Laravel 5 project. All right, so we should get a fresh deployment coming out here. There it is. All right, let's take a look at this and let it deploy, and then I'll show you something really cool on the server. So when you're deploying and you're using symlinks, you want to maintain that environment information across your deployments, but of course, how do we get the environment file within the current directory? Remember, it's actually in the base directory one level up. Well, Envoyor will actually intelligently manage syncing that file to your current directory, so it will create a symlink within your current release pointing back.

Symlinking .env and Storage2:52

directory one level up. Well, Envoy will actually intelligently manage syncing that file to your current directory, so it will create a symlink within your current release pointing back to that environment file. All right, so let's take a look on the server now that this is deployed. Okay, we, of course, still have our .env file, but if we go into current and show all the files, you can see right here there's that symlink. It's pointing .env to homeforge/default.env, so it's automatically managing symlinking that for you, so you don't even have to think about it. You get that for free, and of course, it does the same thing with your storage directory, so it's a super convenient way to manage your storage and your environment without even requiring any thought on your part, really, on how that's happening behind the scenes. It's all nice and automatic for you, and of course, it's very convenient to sync your environment.

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