SilverStripe Install with Composer in Windows Environment

Setup Git

Git (Version Control) is required for cloning repositories and managing code.

  1. Download Git installer from Git download page.

  2. Run through installer, and ensure you check “Use Git from the Windows Command Prompt” towards the final step.

Setup Composer

Composer is a PHP Dependency Manager, which saves you from having to manually download PHP libraries and is a more efficient way for ensuring that your code is up to date, as composer makes the process of upgrading third party code achievable with one command.

  1. Go to the Composer download page.

  2. Download the installer.

  3. Install using the wizard with default settings.

  4. Confirm that composer has been installed by loading Command Prompt on your windows server and run 'composer', this should output Composer version, options and available commands.  You may also remote into your Windows server e.g. by use of Cygwin (SSH) or PS-Sessin to avoid having to RDP, this of course is dictated by your environment setup.

Install SilverStripe and SQL Server Module (With Composer)

  1. Create a new directory e.g. newsite.

  2. Create a new db in SQL server (Or MySQL) to hold your db content.

  3. Go to the SilverStripe download page.

  4. Copy and run the composer installation command in your site directory:

  5. Update path/to/project and SilverStripe version.

  6. composer create-project silverstripe/installer /path/to/project 3.1.10

  7. Install SQL Server module to allow silverstripe to use SQL Server.

  8. Note: You will need to change the release number.

  9. composer require silverstripe/mssql "*"

Create a new web site in IIS

  1. Load IIS from Server Manager

  2. Right-click server from list, and select IIS Manager

  3. Right-click server tree and clieck Add Website

  4. Set sitename, phyiscal path of the new site created earlier, IP (127.0.0.1) and hostname (URL).

  5. More details here

  6. Create a new DNS entry to point to your site.

Windows permissions error

You may encounter the following error:
Warning: require_once(core/TempPath.php): failed to open stream: No such file or directory in framework/core/Constants.php.

To resolve this issue, you'll need to apply the following temporary fix (below).
This issue has been reported and a likely fix maybe available.
This issue may also be related.

Replace the following block of code in ~/framework/core/Constants.php

	//check this dir and every parent dir (until we hit the base of the drive)
	// or until we hit a dir we can't read
	while(true) {
		//if it's readable, go ahead
		if (@is_readable($dir)) {
			//if the file exists, then we include it, set relevant vars and break out
			if (file_exists($dir . DIRECTORY_SEPARATOR . $envFile)) {
				define('SS_ENVIRONMENT_FILE', $dir . DIRECTORY_SEPARATOR . $envFile);
				include_once(SS_ENVIRONMENT_FILE);
				//break out of BOTH loops because we found the $envFile
				break(2);
			}
		}
		else {
			//break out of the while loop, we can't read the dir
			break;
		}
		if (dirname($dir) == $dir) {
			// here we need to check that the path of the last dir and the next one are
			// not the same, if they are, we have hit the root of the drive
			break;
		}
		//go up a directory
		$dir = dirname($dir);
	}

with

	do {
		// add the trailing slash we need to concatenate properly
		$dir.= DIRECTORY_SEPARATOR;

		// if it's readable, go ahead
		if (@is_readable($dir)) {
			// if the file exists, then we include it, set relevant vars and break out
			if (file_exists($dir . $envFile)) {
				define('SS_ENVIRONMENT_FILE', $dir . $envFile);
				include_once (SS_ENVIRONMENT_FILE);

				// break out of BOTH loops because we found the $envFile
				break(2);
			}
		} else {
			// break out of the while loop, we can't read the dir
			break;
		}

		// go up a directory
		$dir = dirname($dir);

		// here we need to check that the path of the last dir and the next one are
		// not the same, if they are, we have hit the root of the drive

	} while (dirname($dir) != $dir);

Installation

  1. Create a DB in SQL server.

  2. Load site, you should now see the installation page.

  3. In Database Configuration, select SQL Server and set credentials.

  4. Set admin email and password.

  5. Start SilverStripe installation.

Track Project with Git

Now that you have installed SilverStripe CMS, its time to check in the code into Git.
View Git documentation

Go to project dir.

Create an empty Git repository

git init

Add the following directory names at the end of .gitignore file, this ensures that the code isn't checked in into the repository as it is now managed with composer:

cms/
framework/
mssql/

Add (Or stage in git terminology) the content to the index to prepare for the next commit.

git add .

Add a commit message

git commit -m 'Initial site setup'

Add the git remote settings:

git remote add origin <url>

Push your commit into the repo:

git push -u origin master