Follow these steps to understand how to deploy a CakePHP application to the cloud. While some cloud providers offer simple solutions, you will notice that others require a bit more technical know-how for you to deploy an app.
In this article we’re going to show you how to deploy a CakePHP application to the cloud. We’ll take it step by step and show you how to deploy an app to Microsoft Azure as well as Amazon AWS (using Elastic Beanstalk).
For those who are not tech-savvy, coding can be a little frightening. That’s why we’re also going to show you the easiest way you can deploy a CakePHP to any cloud by using Bunnyshell. It’s faster, works better, and it saves you a lot of time and overhead.
Let’s start with the basics:
CakePHP is an open-source framework that makes it easier for you to develop and manage any PHP application. For those who don’t want to spend a lot of time coding, and instead focus on app development and design, CakePHP is a great framework. Less coding, more action!
Using a framework instead of pure code is better, especially if you are new to coding. Frameworks like CakePHP come with systems that already contain best practices in “how” your application should be structured and how development needs to be done.
CakePHP itself is a great framework and comes with:
Even before you’ve finished working on your application, you’ll still need to deploy it. You don’t want to risk losing the updates, right?
Before you do, there are a few steps you need to go through:
1. Start by Moving files:
You need to create a git commit and pull or clone that commit or repository on your server and run composer install.
Be aware that when deploying via FTP you will at least have to fix the file and folder permissions.
You can also use this deployment technique to set up any staging- or demo-server and keep it in sync with your dev box.
2. Afterwards, make sure to Adjust config/app.php
Turning debug = false disables a number of development features that should never be exposed to the Internet at large.
This will help you avoid deploying any application with debug true and also save yourself from having to change the debug level every time before deploying to a production environment.
3. Don’t forget to Check your security
You’ll want to have your webroot directory publicly visible. Make sure that your secrets (such as your app salt, and all security keys) are private and unique. Do not forget to check if your models have the correct validation rules enabled.
4. Next, you will want to Set document root
CakePHP applications need to have the document root set to the application’s webroot. This makes the apps and configuration files inaccessible through a URL.
5. Finally, once your CakePHP app is deployed, improve your application’s performance
To do so, you will need to run this command in your production server:
php composer.phar dump-autoload -o
Now that you know the basic steps to deploying a CakePHP application to the cloud, let’s take a look at how you can do it on two of the most important cloud providers: Microsoft Azure and AWS.
The needs:
To deploy a CakePHP application to Azure you will need:
Some cloud providers make it easier for their users to deploy an app, while others go the old fashion way.
Microsoft Azure seems to be a bit more complicated when it comes to deployments, but it’s actually easier than it seems. Here’s what you need to do before deployment:
1. Create an empty Azure Web Apps and enable Composer extension. If you want, you can enable Visual Studio Online for easy script modifications and command running.
2. Create a file named web.config in the root directory of your application.
3. Add the inlt extension in PHP runtime on Azure. Next, add a folder with the name ext in your root directory and create a file ext.ini in the folder you just created with the content:
extension=php_intl.dll.
4. Add an App Setting to your Web App with the following key:
PHP_INI_SCAN_DIR.
Also, make sure to add the value
d:\home\site\wwwroot\ext
After deployment, you also can do this step to leverage Visual Studio Online extension.
5. Finally, you will need to set up the development environment of your Azure Web Apps and deploy your CakePHP application to Azure via Git.
Deploying the CakePHP application via Git is easy:
<deploymentLocalGitUrl-from-create-step>
with the URL of the Git remoteCongrats! You’ve successfully deployed your CakePHP application to Azure!
Now that you have deployed your CakePHP application, you can focus on improving and upgrading the app without fearing that you might make a coding error and ruin your process so far.
The needs:
In order to deploy a CakePHP application to AWS you will need:
To deploy your CakePHP application to AWS you’ll want to use Elastic BeanStalk – an orchestration service offered by Amazon Web Services to help its users deploy applications.
With Elastic Beanstalk you will be able to deploy your CakePHP application in no time, by following a few simple steps:
cake-default.zip
. This also excludes files in the vendor folder, which take up a lot of space. Don’t worry, they are not necessary for the deployment process. As you can see, each cloud provider has its own set of steps that you need to follow to deploy a CakePHP application. If you’re using both of these cloud providers, manually deploying your app could become a time-consuming and repetitive task.
Looking for a better solution? Keep on reading!
The needs:
In order to deploy a CakePHP application to any cloud with Bunnyshell you will need:
Bunnyshell helps you manage and automate your cloud infrastructure. Creating and deploying applications is easier, faster and more secure, no matter which cloud provider you’re using.
With Bunnyshell, you can deploy your applications directly from Git Repository: just log into your Bunnyshell account, connect your Git Repository, select the application and deploy it. You can also create and deploy your CakePHP applications directly in Bunnyshell, with no repository needed.
Let’s take a look at how you can create and deploy your CakePHP application:
Once you finish creating the application, you can deploy it by going to your Application view, specifying the branch or tag you want to deploy, and hitting the Deploy button.
Instant deployments, with just one click. Deploying a CakePHP application in AWS, Azure, or in any other cloud doesn’t have to be a manual, time-consuming task. With Bunnyshell, you can automate these repetitive tasks and boost your end-user experience through agile deployment.
Previously published at https://www.bunnyshell.com/blog/cakephp-application-cloud/