All About the Directory Structure in Silverstripe

Silverstripe

Silverstripe is one small community that is remarkably growing with the passing time. And AddWeb, having sensed its strength, had picked it quite some time back. Just after having worked on a handful of Silverstripe projects, we started giving it back to the community in whichever way that we can - modules, patches, blogs, et al. Yes, previously also we’ve shared SilverStripe Blogs on the rich bank of modules and themes available in SilverStripe, How to operate the administrative panel of SilverStripe CMS and how powerful is this platform called SilverStripe.

Now, let’s start with sharing some technical tutorials. To start with, we’ll like to share the detailed directory structure in Silverstripe.

In SilverStripe, the directory structure is built on the convention rather than the configuration, which is why the placement of certain files and directories is pretty logical in general. There are various sub-structures and even further divisions of the same, fall under the directory structure in SilverStripe. Let talk about the Code Structure first and the sub-structures of the same. 

Code Structure :

silverstripe

 

  • app/: 

           This directory contains all the codes that define the website.

 

  • Public:

          Web Server public webroot.

 

  • public/assests

          Images and other files are uploaded via CMS into this folder. You can also keep your own files and images in this folder.

 

  • Public/resources: 

          Exposed public files are added from the module. Folders within this parent will match that with the source root location.

 

  • Vendor/: 

          SilverStripe modules and libraries are stored in this folder. (the framework is in vendor/SilverStripe/framework)

 

  • themes/:

         This is the standard theme location.

 

Customization of the Code:

 

  • app/: 

          This directory contains all the code that defines the website.

 

  • app/_config: 

          This directory contains YAML configuration specific, meant for the website.

 

  • app/src: 

          This directory contains the PHP code for the model and the controller.

 

  • app/test: 

         You can do PHP unit testing here by using this folder.

 

  • app/templates:

         You can add your view i.e. the HTML files here with the .ss extension for the $default theme.  

 

  •  app/CSS:

          You can design the CSS files here. 

 

  •  app/images:

           Images used all over the website are saved here. 

 

  •  app/javascript:

           JavaScripts and other scripts files are located here. 

 

  •  app/client:

          The more complex projects can alternatively contain frontend assets in a common client folder.

 

Theme Code Structure:

          Custom theme directory differs a bit from the usual one. Here’s sharing details for the same. 

 

  • themes/simple:

          Its a default standard theme provided by SilverStripe.

 

  • themes/<your-theme name>: 

         Custom theme base directory.

 

  • themes/<your-theme name>/templates: 

         Custom theme template.

 

  • themes/<your-theme name>/CSS: 

         Custom theme CSS files.

 


Module Code Structure:

       When you add some module to the website then its directory structure also changes. Hence, here’s sharing the details of the same.
Say, for instance, you installed the userform module. In that case, below would the module code structure for the same.

 

  • vendor/silverstripe/userforms:

         This directory contains all the codes for user-defined form.

 

  • vendor/silverstripe/userforms/code:

         This directory contains all the codes of every model, controller, and extension of the user defined forms.

 

  • vendor/silverstripe/userforms/_config:

         This directory contains all the YAML files.

 

  • vendor/silverstripe/userforms/images:

         This directory contains all images which are used for the userform module.


Hope, you found this detailed Directory Structure in SilverStripe helpful. In case, by the end of the blog, you’ve come across a handful of queries, you can go ahead and share them with us. Also, feel free to share/add more knowledge on the same with us. Because it’s all about sharing with and for the community. Isn’t it?