Best way to deploy a project?

Silverstripe Version:

Up until now I’ve been deploying my SilverStripe site simply using FTP to upload the files to the host. I have a different .env file on my local copy to what is on the host and use vendor expose copy to ensure all relevant assets are updated. This is all well and good, except it can be quite tedious if I update the project or SilverStripe files as it’s then hard to keep the 2 copies nicely synchronised and uploading can be very slow.

I’m aware that there’s better deployment options out there, but I’m unsure which to choose or how to go about setting them up with minimal interruption to my current configuration. I don’t have a git repository, nor do I know how to set this up or if this is even the way to go?

Some advice on this would be greatly appreciated!

I guess the first question is: Can you access your hosting environment via SSH?

If so, then the next question is probably: Are you currently using Composer (Composer – SilverStripe Documentation)?

At a bare minimum, using composer and then only syncing your project files to the server, then logging in via SSH and running composer install --no-dev will pull down all the project dependencies.

Beyond that, a lot of people now use deployer ( to automate pushing files to the server, running composer, dev/build, etc. But you will need a git repo to connect deployer to.

Hope that helps a bit…

1 Like

I use Beam GitHub - heyday/beam: A command line utility for deploying websites to servers

I can tell this heavily depends on a lot of factors.

  • Hosting
  • Team size and structure
  • SDLC (the development practices you follow)
    • QA processes and development workflow
    • Continuous Integration / Continuous Deployment

As it’s been mentioned above, version control is very helpful for even one person team. E.g. even if you don’t want to rely on composer, might do a simple git pull, which would synchronize all the files for you with the repository. Either way, it’s important to have a single source of truth (usually that’s a main project repository).
When the team is growing, it may be worth considering to go for Continuous Integration / Continuous Deployment practices. In that case deployment would be automatically triggered by pushing to a particular branch in the project repository. In that case Continuous Integration platform would run the tests for you and then deploy to servers (could be using deployer there or maybe something else). This may be helpful even for 1 person team, depending on the development practices followed.
Surely, there are a lot of other ways to deal with deployments and most of them are suiting particular team workflows. For huge projects there could even be complex multi-step deployment pipelines with responsible team members reviewing and formally approving deployments along the way (e.g. AWS CodeDeploy).

Either way, I’d suggest starting with version control and continuous integration.

I have the following:

  • local dev environment using MAMP, installation with composer all working fine
  • GitHub repository which I can push changes to from local machine
  • CPanel repository on web host which pulls changes from GitHub repo
    This all seems to be working fine, ie. I can make a change on my local machine, push to GitHub, pull changes onto web host via CPanel Git VersionControl

In order to deploy, I need to set up a .cpanel.yml file as described in

I have tested this with their example using a single file or directory and also working fine, ie. .cpanel.yml is checked into repo and once pulled onto web host via CPanel allows me to manually deploy.

So, I’m just wondering which commands should I use in the .cpanel.yml file? Is the following sufficient, or is there more that I should be adding? In particular, how do I ensure that old project files (ie. files no longer on repo) get removed? I really want to be able to sync changes with repo.

    - export DEPLOYPATH=/home/username/testwebsite/
    - /bin/cp -R * $DEPLOYPATH
    - composer install --no-dev -o

Note I haven’t yet tested whether composer install will work in this context. If anyone has any experience with using CPanel Git deployment, I’d be interested to know what you do :slight_smile: