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

Default PHP in Forge0:01

When we first spin up a server in Forge, by default, it's just gonna give us the latest version of PHP to run it. But if we want, we can go to our advanced settings and we can choose which version of PHP is the primary version. But outside of that version, all the settings are gonna be default, and there's only gonna be one version installed, and that's okay for most applications. But if you need to customize your PHP install

Navigating the PHP Tab0:17

and that's okay for most applications. But if you need to customize your PHP install or have more than one, it is possible in Forge. So let's dive into how to do it. Let's head over to our server and check out the PHP tab. Now, the PHP tab has three sections, settings, which we'll cover today, and then composer and Engine X templates, which we will look at in later videos. Settings is broken down into two things,

Tuning Common PHP Settings0:36

which we will look at in later videos. Settings is broken down into two things, settings and versions. So let's look at the settings first. These are some generic, uh, configurations that are very common for you need to configure it in your LABLE applications. The Max file upload size defines how big a file can be before PHP is gonna throw an error. You often have to modify this

before PHP is gonna throw an error. You often have to modify this because, for example, people need to be able to upload files directly from their iPhone, and those might be six megabytes and the max execution time, which is said to something reasonable. So you don't have scripts running for five minutes without realizing it, but sometimes that actually is exactly what you want.

Understanding OPcache Caveats1:05

for five minutes without realizing it, but sometimes that actually is exactly what you want. So you can customize it here. Finally, we've got this third thing, which is opc. And if you're not familiar with opc, it is a tool that compiles your PHP code and stores it in memory and it'll make your code faster, but it brings a few caveats along with it. Most importantly, you need to restart PHP FPM after it deploys, but that actually is usually set

Most importantly, you need to restart PHP FPM after it deploys, but that actually is usually set by default in the forge deploys. But there are a few more complicated aspects about it. So I'm not saying don't try opc. I'm saying try your own risk and make sure you educate yourself before you turn it on. Okay, so at the bottom here we can see all the versions of PHP we have installed by default. It's just that one that we created

Installing Additional PHP Versions1:41

of PHP we have installed by default. It's just that one that we created when we installed the server. So let's start by adding an additional version of PHP. I'm gonna install an older site that needs PHP 8.3 running. And now that we're in this modal, we can see there's these two default settings here. Set is default for CLI means if I go to my server and I type PHP, this is the version that's gonna pop up. And I can still type PHP 8.4 or PHP 8.3

and I type PHP, this is the version that's gonna pop up. And I can still type PHP 8.4 or PHP 8.3 or whatever else to get that specific version on the CLI. But this right here defines which one responds to just PHP. And default for new sites means that if I create new sites on the server, what version are they gonna be? By default, it'll be the original, so 8.4. But if I click this right here and I create a new site, it will now be PHP 8.3 instead.

But if I click this right here and I create a new site, it will now be PHP 8.3 instead. And when you actually go back here, you can see there are labels for each of these instead. Finally, for each version we have installed, you can click on the three dots and we can take a few more actions. We can edit the configuration for PHP FPM, which is calls through HTTP, like browser visits. We can edit the PHP command line configuration.

Assigning Versions to Sites2:38

through HTTP, like browser visits. We can edit the PHP command line configuration. We can edit the PHP pool configuration, and also we can update this specific version to the latest patch update or the LA latest dot release of that version. Finally, there are a few other places we can interact with these specific PHV versions. So if we were to go to our logs, you'll find that there's a specific log file for each version

So if we were to go to our logs, you'll find that there's a specific log file for each version of PHP that you have running. So we would've a PHP 8.4 and a PHP 8.3 log file. Or if we were to go to an existing site, we can go to our settings and we can choose which version of PHP this one's running on. And when we create a new site, we go to our advanced settings and we can choose which version of PHP that it's running on.

we go to our advanced settings and we can choose which version of PHP that it's running on.

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