Setting up a development environment

Successful development of a Silverstripe Cloud website relies on the ability to use the provided services and tools and build upon them to provide custom functionality where needed. A description of the high-level technical architecture is available on request.

Silverstripe Cloud projects are installed using the Composer PHP package management tool. For general information about Composer, visit the Silverstripe Composer documentation or read the installation documentation on the Composer site.

Please familiarise yourself with the CMS recipes before starting to develop on Silverstripe Cloud. To ensure your code works smoothly with the in-nation/ CCL infrastructure platform it's important to start from the stable release of the CMS CCL Recipe module.

Example project setup

Time should be taken to consider what modules you wish to install for your project. An example might follow steps like the below:

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 a new project using Composer by running the following command:
composer create-project silverstripe/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 Silverstripe Cloud Public Sector (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. Then, install the public sector-specific recipe:
composer require silverstripe/recipe-ccl
5. cd my-project to move into your new project folder
6. 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.

Environment file

Whether you follow the above steps, or something else, you should also do the following:

1. Create a .env environment file in the /htdocsfolder and fill it in with your local details

To ensure the security of your site, and of Silverstripe Cloud Public Sector in general, please make sure your code can be easily upgraded by maintaining your modules using composer. This will help to keep your dependencies updated with respect to the patch and sub-patch versions of the recipe - read more about CMS recipes.

If you decide to remove the composer.json file and instead commit the modules into the project code, we may not be able to support you because we will have to assume the modules have been customised.

Git

When working with code you will be utilising the Git version control system, and the core repositories will be stored on GitHub, while you are free to store your code wherever you choose. By default, your code will be stored on GitLab. We recommend reading through tutorials on using Git, available online. The Pro Git book is a good reference guide.

Installing Git

If you're on Mac OS X, one way to get Git installed is to get Xcode with the command-line tools component included. Git will be included in that package. You could also install it using the Homebrew package manager.

On Linux, depending on your flavour, the package manager should have Git available so you can install it. On Debian or Ubuntu Linux apt-get install git should be enough to get you started.

On Windows install Git for Windows.

Configuring Git

Apply some configuration changes to git for a smoother experience when working on Git repositories.

Name and email

Set up your global user name and e-mail:

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

These will identify you in code commits that you make.

Increase the default post size

A common issue with using our specific installation of GitLab is the limit to the Git post size on the client-side (developer's machine). It will result in 411 errors showing up when trying to push a significant amount of work to upstream.

The default post size for git is 1 MB. To increase the value run the below command to increase the limit to 500MB:

git config http.postBuffer 524288000

Caching Git passwords

You can avoid having to type the password in every time by using a Git credential helper.

The easiest way is to use the in-built cacher:

git config --global credential.helper cache

You can adjust the timeout period from the default 15 minutes:

git config credential.helper 'cache --timeout=3600'

See this Stackoverflow thread for more information.

This will save you some typing, but not all of it. Another way to approach this is to store the password in a keychain on your machine using the software built by a company called GitHub (not related to GitLab). This will allow you to permanently store your password in a secure manner. The software is available directly from GitHub.

Where to from here?

For more information on correctly setting up your project see Setting up your project. It shows how to set up Git and how to access GitLab to manage your code repositories on the Silverstripe Cloud.

Was this answer helpful? Yes No

Sorry we couldn't be helpful. Help us improve this article with your feedback.