Getting started with Silverstripe’s Common Web Platform (CWP)


  • Share on Google+

This is a short guide for those who are already familiar with SilverStripe development. This will allow you to setup a CWP Gitlab project, repository and a local CWP-configured SilverStripe installation on which you can commit and push code to GitLab.

Before you begin

This guide assumes you already have:

If you’re using Windows, you can use a command-line equivalent to interact with git and composer, offered by the MsysGit package

Have an existing GitLab project?

Follow the instructions at Setting up your project to setup an environment with an existing CWP project.

Getting started with CWP codebase from scratch:

Please replace “my-project” below with the actual name of your project. One naming technique is to use the intended project’s hostname e.g. “my-project.govt.nz” as the project’s folder name

  1. Change into your web server’s document root: cd /var/www/htdocs
  2. Create new project using Composer by running the following command:
    composer create-project cwp/cwp-installer my-project

    This may take some time to run as it is collecting and downloading all the code required to run a default SilverStripe CMS website on CWP (the Recipe code).

  3. If composer asks Do you want to remove the existing VCS (.git, .svn..) history? [Y,n] then choose Y. This removes the existing cwp-installer history so you can turn this into your own project.
  4. cd my-project to move into your new project folder
  5. Make sure your folder permissions are correctly set (see File permission problems), you will also need to create an ‘assets’ folder if one isn’t already created
  6. Create a .env environment file in the /htdocs folder and fill it in with your local details
    • CWP Environment variables has more details about CWP specific variables that you can set in your environment file
    • Environment management has more details about how to create a environment file
    • Adding SS_SEND_ALL_EMAILS_TO='your@address.govt.nz' stops any debugging emails going out accidentally to live emails
  7. Now run a build of the database either by going to http://localhost/my-project/dev/build?flush=1 or using Sake to run the dev/build via the command line vendor/bin/sake dev/build

You should now be able to visit: http://localhost/my-project and see a basic CWP-themed site in your browser.

For a more in-depth walkthrough through CWP development activities, please refer to “Working with projects”. Even if you already know how to develop in SilverStripe, please review our Performance Guideto ensure you create a stable and performant site.

Troubleshooting

Q: I can’t complete the composer install command. PHP says: “Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in phar:///usr/bin/composer”

A: Some of the modules that composer needs e.g. “framework” and “cms” are rather large and composer needs more memory to complete the requests.

Increase the memory_limit setting in php.ini to something higher than the default of 128Mb e.g. 256Mb or 512Mb and then re-try.

HAVE A PROJECT IN MIND?

Get a free same-day website design ballpark quote and roadmap proposal.

We will only send your quote and wont share your email address.