Top Banner
SilverStripe Framework Building without the CMS
38

SilverStripe Framework - Building without the CMS

Apr 16, 2017

Download

Technology

Daniel Hensby
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SilverStripe Framework - Building without the CMS

SilverStripe FrameworkBuilding without the CMS

Page 2: SilverStripe Framework - Building 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

Page 3: SilverStripe Framework - Building without the CMS

Why would you even...

But the CMS is one of SilverStripe’s USPs!

Page 4: SilverStripe Framework - Building without the CMS

Why would you even...

Page 5: SilverStripe Framework - Building without the CMS

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!

Page 6: SilverStripe Framework - Building without the CMS

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

Page 7: SilverStripe Framework - Building without the CMS

So why throw it away?

Speed gains

Reduce bloat

No requirement for managing site structure or content

Highly dynamic pages

Page 8: SilverStripe Framework - Building without the CMS

Where do we start?

Page 9: SilverStripe Framework - Building without the CMS

Routing

Page 10: SilverStripe Framework - Building without the CMS

Routing

Config system for routing

mysite/_config/routes.yml

Define routes to controllers

Before/After?

Before = LOWER priority

After = HIGHER priority

Page 11: SilverStripe Framework - Building without the CMS

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

Page 12: SilverStripe Framework - Building without the CMS

Putting it into practice

Page 13: SilverStripe Framework - Building without the CMS
Page 14: SilverStripe Framework - Building without the CMS

A Todo App!

Page 15: SilverStripe Framework - Building without the CMS
Page 16: SilverStripe Framework - Building without the CMS
Page 17: SilverStripe Framework - Building without the CMS
Page 18: SilverStripe Framework - Building without the CMS

Nested controllers

Page 19: SilverStripe Framework - Building without the CMS

Nested controllers

Delegating to nested controllers

Prevent creating GOD controllers

Single purpose controllers!

Flexibility to be used anywhere

Page 20: SilverStripe Framework - Building without the CMS

Flexibility

Instead of:

Page 21: SilverStripe Framework - Building without the CMS

Flexibility

We can do:

Page 22: SilverStripe Framework - Building without the CMS

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

Page 23: SilverStripe Framework - Building without the CMS

Add some logic to pull out the current List

Page 24: SilverStripe Framework - Building without the CMS

Put it all together...

Page 25: SilverStripe Framework - Building without the CMS

Sprinkle some fairy dust

Page 26: SilverStripe Framework - Building without the CMS

We have ourselves a todo list app

Page 27: SilverStripe Framework - Building without the CMS

What about administration?

Page 28: SilverStripe Framework - Building without the CMS

CRUD out of the box?

Page 29: SilverStripe Framework - Building without the CMS

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)

Page 30: SilverStripe Framework - Building without the CMS
Page 31: SilverStripe Framework - Building without the CMS

CRUD out of the box?

Page 32: SilverStripe Framework - Building without the CMS
Page 33: SilverStripe Framework - Building without the CMS

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)

Page 34: SilverStripe Framework - Building without the CMS

What did we learn?

Page 35: SilverStripe Framework - Building without the CMS
Page 36: SilverStripe Framework - Building without the CMS

Everything else stays the same

Define your

Routes

Controllers

Models

Relationships

Views

Forms

Change the world!

Page 37: SilverStripe Framework - Building without the CMS

or… just build a to-do list app

Page 38: SilverStripe Framework - Building without the CMS

Thanksgithub.com/dhensby/todo-list

@dhensby (everywhere!!)