Developers have different options and tools to create automatic deployments for their projects on any hosting for PHP. These automatic deployments options ensure that no time is wasted on adding new coding blocks manually between the files on a Live server. The good news is that developers choose from a lot of deployment tools now including DeployBot and DeployHQ.
For the purpose of this article, I’ve picked the popular zero-time deployment tool ‘Envoyer’, created by Laravel’s creator Taylor Otwell. While Envoyer is considered the “default” option for deploying Laravel apps, I will demonstrate how to deploy Symfony applications on Cloudways using this tool.
The team behind Symfony recently published the latest versions of Symfony, 3.4 and 4.0. These versions have different structure when compared to the standard release versions. I will not go into the details of Symfony 4. Similarly, if you wish to upgrade Symfony 3.x to version 4, follow this detailed upgrade guide.
So now, back to the point.
Envoyer is a deployment tool used for the deployment of PHP applications. The best thing about the the tool is the zero downtime during deployment. This means that your application and the customers using it are not even aware of the fact that a new version has been pushed. Envoyer works well with major repository management platforms such as Github,GitLab and Bitbucket. Other benefits include unlimited deployments and team members.
The following tutorial will guide you through the process of deploying Symfony applications on Cloudways using Envoyer.
Create an Envoyer Account and Add a Project
Create an Envoyer account and login to it. Next, add a new project. For the purpose of this tutorial, I am signing in using my Github account.
Connect Your GitHub Repository
Next, connect your Github Repository. Just copy the username/repository for Github repo URL and paste it in the input box. Since, I am not deploying a Laravel app, choose the Other radio button, and hit the Save Project button.
The project will be added to the account and the GitHub repository will now be connected to Envoyer.
Add the Server
The next step is to integrate the Cloudways server. For this, head to the Server tab and click the Add Server button.
Next, login to your Cloudways account and get the credentials for adding the server from the Master Credentials section inside the Server Management tab of the Cloudways Console.
Fill out all the required fields and enter the complete absolute path of your Cloudways application and save the server.
After saving the server, you will be provided with a SSH key.
Copy the key and head over to your Cloudways Console and click the ‘SSH Public Keys’ button. Give a label to your key and click Submit.
After adding the SSH key, you should be able to connect to your server. Click the tiny Refresh button to test the connection status.
At this point, everything is correctly set up. The final step is to click the Deploy button for actual project deployment. You can also deploy applications via Git Push by selecting ‘Deploy when code is pushed’ option in the settings.
Envoyer will ask you from which branch or tag you need to deploy the application code. I selected the Default Branch, which is the master branch as well.
Hit the Deploy button now.The deployment process could be viewed in the deployment tab. You can get additional information related to deployment by clicking the arrow button next to the deployment status.
You can clearly see that Envoyer takes minimal time to deploy the application on your server.
Deployment Folders on Cloudways
Once deployed, login to the SSH terminal on Cloudways, and move to your application folder. You will find two folders, current & releases.
The current folder have the main application which is in development and the release folder contains the previous releases folder named with date and time of the deployments.
You could check the status of your application from three locations(New York, London, Singapore). In case of a disaster, you have the option of rolling back the current deployment. For this, enable this option by providing the health check URL in the settings. Additionally you can set up heartbeats to monitor cron jobs for your application. You could also set up a notification channel like Slack and Hipchat to receive deployment related notifications.
Wrapping it all up
As you could see, Envoyer is a great option to deploy Symfony and other PHP apps. The process is simple and you could directly connect the process to a version control platform to ensure that the latest version of the app is deployed at all times. If you need help with the process, do post a comment, and I will get back to you.
Shahroze is a PHP Community Manager at Cloudways - A Managed PHP Hosting Platform. He’s always in search of new frameworks and methods to implement them. Besides his coding life, he loves movies and playing soccer with friends. You can email him at firstname.lastname@example.org
Create PHP websites without the worry of server management.
Deploy your PHP app on optimized PHP hosting servers.