Silverstripe boilerplate module
Simple boilerplate to help kick start a new Silverstripe module., (*1)
Creating a new module
Quickly setup a new module skeleton by cloning this repository and deleting the .git folder., (*2)
To do this in one line, from the command line run:
(Replace MyModuleFolder
with name of the folder where you want to create your new module.), (*3)
Windows
Using Composer, (*4)
cmd /V /C "set "SS_MODULE_DIR=MyModuleFolder" && composer require gdmedia/silverstripe-module-boilerplate && move silverstripe-module-boilerplate !SS_MODULE_DIR! && composer remove gdmedia/silverstripe-module-boilerplate && IF EXIST !SS_MODULE_DIR!\.git rmdir /q /s !SS_MODULE_DIR!\.git"
Using GIT, (*5)
cmd /V /C "set "SS_MODULE_DIR=MyModuleFolder" && git clone https://github.com/guru-digital/silverstripe-module-boilerplate.git !SS_MODULE_DIR! && rmdir /q /s !SS_MODULE_DIR!\.git"
*nix
Using Composer, (*6)
SS_MODULE_DIR=MyModuleFolder && composer require --prefer-dist gdmedia/silverstripe-module-boilerplate && mv silverstripe-module-boilerplate $SS_MODULE_DIR && composer remove gdmedia/silverstripe-module-boilerplate && [ -d ${SS_MODULE_DIR}/.git ] && rm -r ${SS_MODULE_DIR}/.git
Using GIT, (*7)
SS_MODULE_DIR=MyModuleFolder && git clone https://github.com/guru-digital/silverstripe-module-boilerplate.git $SS_MODULE_DIR && rm -rf ${SS_MODULE_DIR}/.git
Grunt
You can use Grunt to quickly rename the boiler plate file names and place holders., (*8)
grunt rename-project
To use, after installing with the steps above:
* Edit package.json
and update the values to suit your new module.
* Edit Gruntfile.js
- lines 5 to 9
and update the values to suit your new module.
* From the command line run:
(Replace MyModuleFolder
with name of the folder where you want to create your new module.), (*9)
cd MyModuleFolder
npm install
grunt rename-project
This will:
* Replace all place holder values in all files with related values from package.json
and Gruntfile.js
- lines 5 to 9
* Update composer.json
and bower.json
from the corresponding values in package.json
* Rename the following files, replacing MyModule
with the value of prefix
in Gruntfile.js
* assets\css\MyModuleCSS.css
* assets\images\sitetree-images\MyModulePageIcon.png
* assets\javascript\MyModuleJS.js
* code\Extension\MyModuleDataExtension.php
* code\Extension\MyModuleExtension.php
* code\PageTypes\MyModulePage.php, (*10)
grunt update_json
Running grunt update_json
will update composer.json
and bower.json
from the corresponding values in package.json
, (*11)
grunt jshint
Running grunt jshint
will run js hint over all non-minified javascript files in assets/javascript
, (*12)
grunt uglify
Running grunt uglify
will run minify javascript files in assets/javascript
, (*13)
grunt cssmin
Running grunt cssmin
will run minify CSS files in assets/css
, (*14)
grunt default
Running grunt default
will run the update_json
, jshint
, uglify
and cssmin
tasks one after another., (*15)
Pull requests welcome!
If you have a class, file or anything else that may be handy to have in this boilerplate, submit an issue or pull request, (*16)