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:

  1. 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:

    Screenshot of the create site form


  2. Create a new database: Navigate to "Database" on the left. Ideally you want to create a database user for each project following:

    Froge form to create a new database for your SilverStripe 4 project


  3. 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:

    Connect git repository to Laravel Forge


  4. 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 .env-file for SilverStripe4 hosted on Laravel Forge


  5. 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:

    Deploy script for Laravel Forge hosting a SilverStripe 4 instance


  6. 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:

    Enable automatical deployments on Laravel Forge

    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.