Beginning a SilverStripe Project

To get up and running, you'll need PHP installed, database software such as MySQL, and a server such as Apache. There are several turnkey solutions that can be installed easily such as MAMP, WAMP and AMPPS.

Once those are installed, you can move on to installing SilverStrip itself. As with all modern PHP frameworks, Composer is the recommended method. If you don't have Composer installed, here are the official instructions for installation on *nix, OSX and Windows.

To install SilverStripe with Composer, run:

composer create-project silverstripe/installer project-name

When Composer finishes installing SilverStripe, visit your server address followed by 'project-name'. Depending on your software and configuration, it will be something like: http://localhost:8888/recipes

There you will fill-in information such as the username and password for your database software, a database name, as well as the admin username and password to the SilverStripe CMS. Once the installation is complete, click the link to delete the installation files as they are a security risk.

You may want to edit your .env file (in SilverStripe v4 installations). In particular, adding this line will allow you to view detailed error information and will make debugging much easier:

SS_ENVIRONMENT_TYPE='dev'

Once it's all installed, you can beginning adding your models, view and controllers.

You can create a simple SS HomePage Model like so:

use Page;

class HomePage extends Page
{

}

 

If you added the environment type to the .env file (mentioned above), after committing your changes to the database, you will receive an error:

[User Warning] It is recommended to define a table_name for your 'SilverStripe\Taskmanager\HomePage'. Not defining a table_name may cause subsequent table names to be too long and may not be supported by your current database engine, the generated naming scheme will also change when upgrading to SilverStripe 5.0 and potentially break.

It looks like this:

ss-define-tablename-error

 

While SilverStripe has no problem adding a table name based on the classname, it seems to want an explicit table name declared inside the model. Until you do so, you may not be able to access the CMS unless you turn debugging off. This issue is unique to SilverStripe v4.

Luckily the solution is simple: add the table name to the class definition:

private static $table_name = 'HomePage';

Then flush the cache by appending ?flush to the URL, and the error will disappear.