Wellington meetup SilverStripe 4 upgrading presentation (Feb 2017)
SilverStripe Framework - Building without the CMS
-
Upload
daniel-hensby -
Category
Technology
-
view
586 -
download
0
Transcript of SilverStripe Framework - Building without the CMS
SilverStripe FrameworkBuilding without the CMS
What we’ll cover
Why?! Just why?
What does the CMS take care of for us?
Setting up routes
Handing off to nested controllers
What about a CRUD* interface?
*Create, Read, Update, Delete
Why would you even...
But the CMS is one of SilverStripe’s USPs!
Why would you even...
Because:
Quick to get up and running
Easy to define Data Model
Familiarity with framework
Can use existing pipelines and workflows
User management out-of-the-box
Access control / security
Modules!
What does the CMS do?
Takes care of dynamic routing
ModelAsController
Nested routes
Dynamic links to models
Forwarding of old URLs
SiteTree
Pages
Logical hierarchy and menus
Managing Assets
Nice HTTP error templates
So why throw it away?
Speed gains
Reduce bloat
No requirement for managing site structure or content
Highly dynamic pages
Where do we start?
Routing
Routing
Config system for routing
mysite/_config/routes.yml
Define routes to controllers
Before/After?
Before = LOWER priority
After = HIGHER priority
Routing
Handling requests on the Controller
Extra params won’t be removed
Params are parsed when they match
We can create some nice “RESTful” URIs
Putting it into practice
A Todo App!
Nested controllers
Nested controllers
Delegating to nested controllers
Prevent creating GOD controllers
Single purpose controllers!
Flexibility to be used anywhere
Flexibility
Instead of:
Flexibility
We can do:
Routing through nested controllers
GET /todo/1/task/9/delete HTTP/1.1Host: example.com...
todo matches ListController
1/task/9/delete is passed to ListController
1/task matches task action
9/delete is passed to TaskController
Add some logic to pull out the current List
Put it all together...
Sprinkle some fairy dust
We have ourselves a todo list app
What about administration?
CRUD out of the box?
Framework comes with the admin module
CMS extends Admin
Most projects/apps need SOME sort of CRUD interface
Save yourself building an admin interface!
User management / permissions out of the box
Speed up testing
The admin (not CMS)
CRUD out of the box?
Framework comes with the admin module
CMS extends Admin
Most projects/apps need SOME sort of CRUD interface
Save yourself building an admin interface!
User management / permissions out of the box
Speed up testing
The admin (not CMS)
What did we learn?
Everything else stays the same
Define your
Routes
Controllers
Models
Relationships
Views
Forms
Change the world!
or… just build a to-do list app
Thanksgithub.com/dhensby/todo-list
@dhensby (everywhere!!)