Using Laravel Forge to host SilverStripe 4
A few years ago during a SilverStripe meetup in Wellington Ingo Schommer mentioned that SilverStripe 4 will be a "better citizen of PHP world". With this he was pointing to goal to support the PSR standards for the then-future versions of SilverStripe. Now, SilverStripe 4 is here and in daily use. We can leverage on the hard work done to get the popular CMS to be PSR compliant.
At bring your own ideas we are using both SilverStripe 4 as well as Laravel heavily. The Laravel ecosystem comes with a lot of great tools build by Taylor Otwell and others. One of these great tools is Laravel Forge. Forge allows you to manage your servers easily. Configuring this for SilverStripe 4 is as simple as configuring it for Laravel.
Once you have signed up create and connect your server(s) at the your provider of choice. After this you will need to complete the following steps:
- Add a new site: Click through to your web server and fill in the form to create a new site with the domain name you are intending to use:
- Create a new database: Navigate to "Database" on the left. Ideally you want to create a database user for each project following:
- Configure git: Navigate back to "Sites" and select your site in the list below the create form. Select "Git repository" and enter the information in the form:
- Configure .env-file: Select the "Environment"-menu point and click on the green "Edit Environment"-button and fill in the form similar to this:
- Configure deployment script: One of the last steps required is a tweak of the deploy script to run dev/build during the deployment. The script needs to roughly look like this:
- Enable automatic deployments: To use the full convenience of automatic deployments on push you should enable automatic deployments on pushing to/merging into the master branch:
This step is optional, but highly recommended.
With these six (5 plus 1) steps you are able to host SilverStripe 4 websites on Laravel Forge. There is no need to actually have an Laravel app on the server(s). This approach can be used with or without any Laravel sites/applications being actually hosted there.
SilverStripe Hosting
If hosting your SilverStripe site is topic for you, you might want to check out our article explaining the different SilverStripe hosting options. Alternatively, you can get in touch to discuss your needs in detail.