Whether you have already worked with other content management systems (CMS) or you are a newcomer to this area, SilverStripe's approach and specific feature set will show you something new. It's a flexible and powerful tool for creating both websites and web applications — catering to the requirements of highly customized or out-of-the-box installations.
In this chapter we'll take a short look at:
Why you should use SilverStripe
How the basic principles and approach of the system work
What the general file structure looks like
What additional resources are available and what to expect from the general ecosystem
As we explore SilverStripe, we will develop a single example project throughout this book. We'll create a website for a bar, enabling the owner to edit various pieces of content himself, including opening hours, prices, and photos. The page will also provide a gallery, contact form, and other interactive parts. Starting with the second chapter, we'll gradually add more and more features and get to know the inner workings of SilverStripe. Later on, we will cover advanced topics such as translating the site, easily managing user data, and sending newsletters.
In case you haven't installed SilverStripe, see the Appendix for detailed instructions. In our example we'll assume that you already have it up and running. Additionally, we won't go into depth explaining the CMS's basics as it's pretty straightforward and well documented. We'll talk about the documentation and support a little later in the chapter.
Whether you were attracted by the "sexy" CMS backend (if you haven't already taken a look at it, you can do so at http://demo.silverstripe.com) or the unique set of features, let's take a short look at some of the most notable characteristics. While some parts might not make a lot of sense or seem appealing at first, you're sure to love them later on.
SilverStripe actually consists of two parts, planned and developed together by the same group of people: the SilverStripe CMS and the Sapphire Framework. Today there are many content management systems and a fair few programming frameworks available. However, SilverStripe's concept of tightly coupling them is a rare but extremely powerful approach. You get the best of two "worlds" and don't need to select one over the other.
This coupling also targets the needs of the two main user groups of the system: developers use the framework to build websites and web applications, whereas content editors rely on the CMS backend.
SilverStripe is a modern system and therefore the code quality is higher than the common perception of PHP products. This also means it can take advantage of newer features in PHP. The benefit of this is that the code you write can be more logical, succinct, and easy to write and change. SilverStripe is not the only modern PHP application in this sense, but this newness does substantially diferentiate it from large, established CMS projects written in PHP and other languages.
Assume you have a simple project with a single developer, Alice and one content editor, Bob.
SilverStripe is a strict supporter of the open source movement. It's even seen as one of the main reasons for its success. Source code, updates, documentation, and more are provided free of charge, and everyone is encouraged to actively participate wherever they see fit.
SilverStripe is released under the Berkeley Software Distribution (BSD) license, a permissive license model originally developed by the University of California, Berkeley. It allows you to copy, modify, and distribute software, even commercially, without having to grant access to the modified source code as long as the original license stays in place. That means you can create your own extensions for paying customers without having to release your changes; most other CMS don't allow this. The BSD license can be found at http://www.opensource.org/licenses/bsd-license.php.
We won't go into too much detail, but here's a brief overview of what developers should expect and how things are done in "SilverStripe land":
Like in any good web application framework, HTML, PHP, and database queries are not mixed but nicely separated in three layers: one for storing information in the database, one containing the logic, and one responsible for the output. This really helps keep the code clean and easy to maintain.
The database layer is abstracted so you don't need to care for various quirks of the different databases. MySQL, PostgreSQL, SQLite, and Microsoft SQL Server are fully supported; an Oracle module is currently being worked on and is marked as experimental. Changes to this layer are also synchronized with the database, saving you from making manual changes in various places.
Customization is achieved through class inheritance, this helps to avoid repetition. Consider our developer Alice and content editor Bob. We could say that both are a "person", having a name, sex, age, and so on. "Developers" additionally have skills like programming languages, while "content editors" don't. Relying on inheritance we could model the entity "person" once and only add specific attributes to the so-called sub classes of "developers" and "content editors" as needed; without having to repeat the basic person information multiple times. This approach is common in programming frameworks, but it's rare for a CMS to support it. The bigger and more complex your system gets, the more this principle will shine as we'll see later on.
SilverStripe's core can be extended by modules (adding functionality, such as a blog), themes (giving your project a different look), and widgets (including small features, such as a map on a contact page).
This folder contains all the files uploaded by website and CMS users. Content editors can access any file under the Files & Images menu point in the CMS backend. Keeping all user files in a single place has two advantages:
Having a clean file structure
Being able to limit SilverStripe's write permissions to this folder
This is a module for rendering your page's sitemap in XML, which improves the communication with search engines. We'll talk more about that in the next chapter. If you don't need this feature you could remove the folder to get rid of it.
mysite/ is a module itself, extending the base system according to our requirements. This folder is the core of any customization. Like in any other module, there is a
mysite/_config.php file, which contains the site's configuration. This includes the database credentials and much more, as we'll see.
While SilverStripe is open source software, the source code is managed and mainly produced by a privately held company, SilverStripe Ltd.. The headquarters are in New Zealand, but there's also a branch in Australia.
This is unusual as most open source projects are developed and maintained by a community without a company in the background. In this case, however, it does not mean that there is a limited, free community edition and a full, commercial one; there is only a single, free version with all the features SilverStripe Ltd. itself uses for its commercial projects.
Based on this model, you actually get the best of two worlds: on the one hand you can freely access the source code, documentation, roadmap, and bug tracker. On the other hand you can easily get commercial support, or the development of whole projects, from the main SilverStripe developers themselves. That's a huge selling point as help is always only a phone call away and you don't have to rely on someone's goodwill to help you. Enterprise-level organizations are likely to require such a support system before even considering making use of specific software.
For more details on the company and the professional services that they provide, visit http://www.silverstripe.com. Source code, documentation, and much more is available on http://www.silverstripe.org.
SilverStripe provides a vast amount of freely available documentation. While this book will cover many different topics and provide you with all the tools needed to accomplish common tasks, it can never include every little detail. And as the development never stops, some features of SilverStripe might change, but such changes will be included in the documentation.
For an overview of all the available resources, head over to http://www.silverstripe.org/help-and-support/.
In order to get to know the nuts and bolts of the CMS take a look at http://userhelp.silverstripe.org. We'll not cover that part in the book as it is very well documented and mainly self-explanatory. It is also available from within the CMS through the Help button.
http://doc.silverstripe.org holds the official documentation, including information on how to install SilverStripe, how to get started, and some more advanced topics. Some articles are more comprehensive than others. This book will cover all the basics and most of the details documented there.
If you are an advanced user, which you will definitely be by the end of this book, you'll be most interested in the Application Programming Interface (API): http://api.silverstripe.org.
While the documentation covers specific tasks step by step, the API describes how specific functions can be called, how they interact, and how to use them in a concise and technical fashion.
The API covers all the available parts of Sapphire, the SilverStripe CMS, and modules created by the core developers.
If you're stuck with a problem or need some advice on how to accomplish a task, don't hesitate to get in touch with the community (for example, if you have problems installing the CMS). It's an ever-increasing pool of like-minded people, actively discussing problems and helping each other. It consists of four main communication channels, detailed below.
http://www.silverstripe.org/forums/ is the official SilverStripe forum, which is a good place to ask general questions as well as get help with specific problems. The response time ranges from minutes to hours, depending on the time of day you post a question. The core developers visit the forum frequently, so you can generally expect helpful responses by them or other community members. Additionally, when you sign up to the forum, you can subscribe to a monthly SilverStripe community newsletter.
IRC is the quickest way of getting help. Depending on the time of day you might have just a few or up to dozens of communication partners. It's especially useful for asking rather simple and short questions and the core developers are also frequently available.
http://groups.google.com/group/silverstripe-dev/ is the place to discuss the general direction and decisions concerning SilverStripe's development. It's a good place to find out what's new and currently under development.
Here you can see the roadmap of the project, review the changelogs, or report bugs you have found: http://open.silverstripe.org
We've already learned quite a lot about the general principles of SilverStripe and its ecosystem, specifically:
Why SilverStripe is unique and distinct from other CMSs and frameworks
Which basic principles are used throughout the system
Which folders are available in general and what they are used for
How SilverStripe is developed and why it's useful to have a company behind an open source project
What resources are available, where to find documentation, and how to get help
In the next chapter, we'll build upon the general concepts we've learned so far by exploring SilverStripe's template engine. This will enable you to create and style the interface of our example project.