-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsilverstripe.html
565 lines (565 loc) · 20.3 KB
/
silverstripe.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>SilverStripe - The South West Pacific's best PHP framework</title>
<meta name="description" content="Introduction and overview of SilverStripe PHP CMS & framework">
<meta name="author" content="Dylan Wagstaff">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/sky.css" id="theme">
<link rel="stylesheet" href="lib/css/zenburn.css">
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!--[if lt IE 9]><script src="lib/js/html5shiv.js"></script><![endif]-->
<style>
ul.socials li{list-style-type:none}
ul.socials img{vertical-align:middle;box-shadow:none;margin-right:0.5em}
div.slides img{border:none}
</style>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<img src="img/SilverStripe_500_transparent.png" alt="SilverStripe" />
<h3>The best PHP framework you've never heard of <small>(probably)</small></h3>
</section>
<section>
<section>
<h2>Tena Koutou</h2>
</section>
<section>
<h2>Who is this guy?</h2>
<p>A web developer. First met Silverstripe in 2008 (v2.2), haven't really looked back much since.</p>
<ul class="socials">
<li><a href="http://twitter.com/nightjarnz"><img src="img/Twitter_logo_blue.png" alt="twitter" class="social" />@NightjarNZ</a></li>
<li><a href="http://github.com/nightjar"><img src="img/GitHub-Mark-64px.png" alt="github" class="social" />Nightjar</a></li>
</ul>
<aside class="notes">
Yarn about how you came across it. And why you stuck with it (nice easy templating).
</aside>
</section>
<section>
<h2>Why SilverStripe?</h2>
<ul>
<li>It's easy.</li>
<li>Which means it makes me look good.</li>
<li>Which means it's better than *XYZ.</li>
</ul>
</section>
<section>
<h2>Trust me.</h2>
<img src="img/SHakG.jpg" alt="This is pretty much my job" />
<p>This is pretty much my job</p>
</section>
</section>
<section>
<section>
<h2>What is Silverstripe?</h2>
<!--img src="img/ssleaves.jpg" alt="Bamboo!" style="float:right;margin-left:0.5em" /-->
<ol>
<li class="fragment">A subtype of Bambusa multiplex <img src="img/ssStem.jpg" alt="Bamboo!" style="float:right;margin-left:0.5em" /></li>
<li class="fragment">Clumping & non invasive</li>
<li class="fragment">Great for privacy screens (hedges)</li>
<li class="fragment"><strong>A seldom searched term</strong></li>
</ol>
</section>
<section>
<h2>What is Silverstripe?</h2>
<ol>
<li class="fragment">A company</li>
<li class="fragment">A great user friendly CMS</li>
<li class="fragment">A fantastic framework</li>
</ol>
<p class="fragment">silverstripe<a href="http://silverstripe.com"><strong>.com</strong></a> & silverstripe<a href="http://silverstripe.org"><strong>.org</strong></a></p>
</section>
<section>
<img src="img/ss3.1.png" alt="Silverstripe CMS v3.1" />
</section>
</section>
<section>
<section>
<h2>Company you say?</h2>
<ol>
<li>Founded in 2000 as Totally Digital</li>
<li>Pre all the things</li>
<li>Simple product ~2001/2, IE only</li>
<li>Grew incrementally until CCK-ish</li>
<li>Tried to be commercial product</li>
<li>Dec. 2005 - Rewrite time!</li>
</ol>
<aside class="notes">
Before drupal & rails were big, huge config array, limiting. Shops preferred Open Source.
</aside>
</section>
<section>
<h2>Giving PHP what it needed</h2>
<ul>
<li>80% web pages, 20% custom dev</li>
<li>Just a CMS not good enough</li>
<li>MVC & DB abstraction</li>
<li>Influenced by rails; active record</li>
<li>Decided to Open Source a month before release</li>
<li>v2 April 2007 - June 2012 (v2.4 May 2010 -> EOL March 2015)</li>
</ul>
</section>
<section>
<h2>Lessons learnt</h2>
<ul>
<li>3.0 released June 2012</li>
<li>Major API overhaul</li>
<li>New config system</li>
<li>New CMS interface</li>
<li>Lightened the core</li>
<li>Framework & CMS decoupled properly</li>
<li>3.1 October 2013, 3.2 on horizon</li>
</ul>
</section>
<section>
<blockquote>
One of the other latent goals of the system that really only came into its own in 3.0 was the idea that CMS is really just a way of managing a set of structured data.
And that, whatever structure you create at the framework level, should be reflected in the CMS: a responsive UI in the sense of being responsive to the data structure
</blockquote>
</section>
</section>
<section>
<section>
<h2>Why should I use it?</h2>
<ul>
<li>Nothing beats it on (dev) speed. Get to go in no time.</li>
<li>Clean code, easy to extend functionality</li>
<li>Fantastic templates</li>
<li>Not just for websites, framework only is the biz too</li>
</ul>
<p class="fragment" style="margin-top:1em"><q><sminnee> yeah. i mean, you can’t force someone to love you :p</q> - Well I'm here to try anyway.</p>
</section>
<section>
<h2>How do I make it tick?</h2>
<ol>
<li>Check all the prerequisites</li>
<li>Drop files</li>
<li>Config file</li>
<li>Build, then flush</li>
<li>???</li>
<li>Profit.</li>
</ol>
</section>
<section>
<h2>Stuff you need</h2>
<ul>
<li>A web server with rewrite capabilities</li>
<li>PHP (duh. Currently 5.3.3+), with required modules</li>
<li>A large-ish memory limit</li>
<li>Database server (MySQL by default)</li>
</ul>
<aside class="notes">
Mostly a default PHP install is fine, excepting + gd & mcrypt (which on most linux distros I've seen have been install separately)
</aside>
</section>
<section>
<h2>Fetch the files</h2>
<pre><code>composer create-project silverstripe/installer ssisthewin</code></pre>
<p>Release archives on website, or grab release (default) branch from Github</p>
</section>
<section>
<h2>Config</h2>
<p>_ss_environment.php</p>
<pre><code>
<?php
define('SS_ENVIRONMENT_TYPE', 'dev');
// These three define set the database connection details.
define('SS_DATABASE_SERVER', 'localhost');
define('SS_DATABASE_USERNAME', 'root');
define('SS_DATABASE_PASSWORD', 'password');
//Name the DB whatever the folder SS is installed into is named
define('SS_DATABASE_CHOOSE_NAME', 1);
//login on first run
define('SS_DEFAULT_ADMIN_USERNAME', 'user@host');
define('SS_DEFAULT_ADMIN_PASSWORD', 'password');
//CLI support!
global $_FILE_TO_URL_MAPPING;
$_FILE_TO_URL_MAPPING['/var/www'] = 'http://mysweetwebsite';
</code></pre>
<p>This file can sit outside the install root <br />(so long as it's in an ancestor)</p>
</section>
<section>
<h2>Make the magic happen</h2>
<p><code>http://domain.test/dev/build</code></p>
<p><code>http://domain.test/?flush=all</code></p>
<p style="margin-top:1em">
Build the manifest, build the database (where necessary), refresh the config, find & cache new template files
</p>
</section>
<section data-transition="linear" data-background="img/devbuild.png" data-background-transition="slide">
</section>
<section>
<h2>???</h2>
<p>Build a theme? Write some code? <em>Create the web.</em></p>
<h2>Profit</h2>
<p>Whatever it is you do to put pounds in your pocket.</p>
</section>
</section>
<section>
<section>
<h2>The CMS is a pleaser</h2>
<ul>
<li>It's the easiest I've ever encountered.</li>
<li>Assets are stored on the files tab.</li>
<li>Media embeds magically with oembed.</li>
<li>Pages fit a type, defining the template to use.</li>
<li>Easy for users to edit, hard to hash up.</li>
</ul>
<p>The developer's CMS - a designer's friend</p>
</section>
<section>
<h2>Code's Basic structure</h2>
<ul>
<li>Everything is a module (including CMS and your site code).</li>
<li>Modules are self contained (assets, etc).</li>
<li>There's a hierarchy to it all (module, theme, project).</li>
</ul>
</section>
</section>
<section>
<section>
<h2>Ok, lets make something quicksmart</h2>
<p>
I know a guy who loves a dirty blog as a simple test. So lets do that.
</p>
<p style="margin-top:1em">
The second tutorial sort of covers this. But we can do better.
</p>
</section>
<section>
<h2>Blog Page</h2>
<p><code>mysite/code/BlogPage.php</code></p>
<pre><code>
<?php
class BlogPage extends Page {
private static $has_many = [
'Posts' => 'BlogPost'
];
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main.Posts', GridField::create('Posts', 'Blog Posts', $this->Posts(), GridFieldConfig_RelationEditor::create()));
return $fields;
}
}
</code></pre>
</section>
<section>
<h2>Guess which letter of MVC this is:</h2>
<p><code>mysite/code/BlogPage.php</code></p>
<pre><code class="php">
class BlogPage_Controller extends Page_Controller {
private static $allowed_actions = ['read'];
public function read() {
return ['Post'=>BlogPost::get()->byID($this->request->param('ID'))];
}
}
</code></pre>
</section>
<section>
<h2>Blog object</h2>
<p><code>mysite/code/BlogPost.php</code></p>
<pre><code class="php">
<?php
class BlogPost extends DataObject {
private static $db = [
'Title' => 'Varchar(200)',
'Body' => 'HTMLText'
];
private static $has_one = [
'Author' => 'Member',
'Page' => 'BlogPage'
];
private static $default_sort = 'Created DESC';
}
</code></pre>
</section>
<section>
<h2>Page Template</h2>
<p><code>(themes/name | mysite) /templates/Layout/BlogPage.ss</code></p>
<pre><code class="html">
<h1>$Title</h1>
<div class="content">$Content</div>
<ul class="posts">
<% loop Posts %>
<li class="post">
<h2><a href="{$Top.Link}read/$ID">$Title</a></h2>
<p>Written by $Author.Name on $Created.Nice</p>
<% if $Created != $LastEdited %>
<p><em>Updated: $LastEdited.Nice</em></p>
<% end_if %>
<p class="intro">$Body.FirstParagraph</p>
</li>
<% end_loop %>
</ul>
</pre></code>
<aside class="notes">
Explain where .FirstParagraph and .Nice come from, what they do, etc. Perhaps point out api.ss.org.nz?
</aside>
</section>
<section>
<h2>Post Template</h2>
<p><code>(themes/name | mysite) /templates/Layout/BlogPage_read.ss</code></p>
<pre><code class="html">
<% with Post %>
<h1>$Title</h1>
<p>Written by $Author.Name on $Created.Nice</p>
<% if $Created != $LastEdited %>
<p><em>Updated: $LastEdited.Nice</em></p>
<% end_if %>
<div class="content">$Body</div>
<% end_with %>
</pre></code>
</section>
<section data-transition="linear" data-background="img/buildingblog.png" data-background-transition="slide">
</section>
<section>
<h2>What about BlogPage?</h2>
<p>Tables sort-of mimic inheritance via joins</p>
<img src="img/tutorial2_data-collation.jpg" alt="visual example of table joining for subclass info" />
</section>
<section data-transition="linear" data-background="img/hammedit.png" data-background-transition="slide">
</section>
<section>
<h2>Fix it fix it fix it</h2>
<pre><code class="php">$fields->addFieldToTab('Root.Main.Posts', #...</code></pre>
<img src="img/tab-paths-customtab.png" alt="Demonstrating tab referencing" />
<p>The docs tell me to remove '.Main'</p>
<pre><code class="php">$fields->addFieldToTab('Root.Posts', #...</code></pre>
</section>
<section data-transition="linear" data-background="img/Post.png" data-background-transition="slide">
</section>
<section data-transition="linear" data-background="img/savepost.png" data-background-transition="slide">
</section>
<section data-transition="linear" data-background="img/unflushed.png" data-background-transition="slide">
</section>
<section>
<h2>Where are my posts!?</h2>
<p>We didn't flush the template cache yet...</p>
<p><code>http://localhost/ssisthewin/blog/?flush=1</code></p>
<img src="img/flush.jpg" alt="don't forget to ?flush=1!" />
</section>
<section data-transition="linear" data-background="img/blog.png" data-background-transition="slide">
</section>
<section data-transition="linear" data-background="img/readpost.png" data-background-transition="slide">
</section>
<section data-transition="linear" data-background="img/blogcms.png" data-background-transition="slide">
</section>
</section>
<section>
<section>
<h2>Ok cool, it makes websites easy. What about proper development?</h2>
<p>Developers wanna see the fun bits!</p>
</section>
<section>
<h2>Magic includes</h2>
<p>Has it's own inbuilt autoloader</p>
</section>
<section>
<h2>Automagic caching</h2>
<p>Advanced options for partial content caching</p>
</section>
<section>
<h2>ORM of champions</h2>
<p>Nothing quite like immutable null object pattern</p>
</section>
<section>
<h2>Easy routing</h2>
<p>Parametrise the URL</p>
</section>
<section>
<h2>Form Fields</h2>
<p>Encapsulation ftw</p>
</section>
<section>
<h2>YAML configuration files</h2>
<p>Declarative, kinda like JS plugins</p>
</section>
<section>
<h2>Extensible without hacking</h2>
<p>Can use <code>Extension</code> kinda like Laravel events</p>
</section>
<section>
<h2>Dependency injection</h2>
<p>::create all the things!</p>
</section>
<section>
<h2>Permissions</h2>
<p>can*()</p>
</section>
</section>
<section>
<section>
<h2>OK, maybe I'll show you these briefly too</h2>
<p>This is getting down the rabbit hole a bit</p>
</section>
<section>
<h2>Lets...</h2>
<ol>
<li>Make blog a module</li>
<li>Add commenting support</li>
<li>... but without touching the module.</li>
</ol>
</section>
</section>
<section>
<section>
<h2>Modules</h2>
<p>The <code>$project</code> folder is already a module...</p>
</section>
<section>
<h2>From this</h2>
<img src="img/premod.png" alt="Pre module file structure" />
</section>
<section>
<h2>To this</h2>
<img src="img/postmod.png" alt="Post module file structure" />
</section>
</section>
<section>
<section>
<h2>Extension & <br />DataExtension</h2>
<p>An underlay applied to a class to provide extra functionality or extend existing ones (appropriate hooks <pre><code class="php">$this->extend('funcName');</code></pre> required).</p>
</section>
<section>
<h2>First Make the comment model</h2>
<pre><code class="php">
<?php
class Comment extends DataObject {
private static $db = [
'Name' => 'Varchar',
'Email' => 'Varchar(100)',
'Comment' => 'Text'
];
private static $has_one = [
'Post' => 'BlogPost',
'Parent' => 'Comment'
];
private static $has_many = [
'Replies' => 'Comment'
];
}
</code></pre>
</section>
<section>
<h2>'Dynamically' add method to BlogPost</h2>
<pre><code class="php">
<?php
class Comments extends DataExtension {
public function getComments() {
return Comment::get()->filter([
'ParentID' => 0,
'PostID' => $this->owner->ID
]);
}
}
</code></pre>
</section>
<section>
<h2>Add things to the controller</h2>
<pre><code class="php">
<?php
class LeaveAComment extends Extension {
private static $allowed_actions = [
'Form'
];
public function Form() {
return Form::create(
$this->owner,
__FUNCTION__,
FieldList::create(
TextField::create('Name'),
EmailField::create('Email'),
TextareaField::create('Comment'),
HiddenField::create('PostID', null, $this->owner->getRequest()->param('ID')),
HiddenField::create('ParentID')
),
FieldList::create(
FormAction::create('doSubmit', 'Comment')
),
RequiredFields::create('Name', 'Email', 'Comment')
);
}
public function doSubmit($data, $form) {
$comment = Comment::create();
$form->saveInto($comment);
$comment->PostID = $this->owner->ID;
$comment->write();
$this->owner->redirectBack();
}
}
</code></pre>
</section>
<section>
<h2>and modify the templates...</h2>
<h2>and edit the config</h2>
<p>Gonna to to code for this part :)</p>
<aside class="notes">
<p>talk folder, example code/mysite/templates. Explain folder structure (root, Layout & Includes), it's only one of the few things that defines a structure.</p>
<p>Explain what you've changed, and why, and how it gets used in preference over the 'core' version. Then explain the include business.</p>
</aside>
</section>
<section data-transition="linear" data-background="img/validation.png" data-background-transition="slide">
</section>
<section data-transition="linear" data-background="img/comments.png" data-background-transition="slide">
</section>
</section>
<section>
<h2>Want to know more?</h2>
<p>Of course you do.</p>
</section>
<section>
<h2>Silverstripe Europe Conf</h2>
<p>PanEuropean meetup <a href="http://silverstripe-europe.org">silverstripe-europe.org</a></p>
<p>3rd & 4th Oct 2014 in Linz, Austria. <br />Free! Register at <a href="http://www.meetup.com/SilverStripe-Europe-Meetup/events/168730312/">Meetup.com</a></p>
<p>CEO of SilverStripe will be attending, and there are intro workshops scheduled too.</p>
</section>
<section>
<h2>(Semi-)Helpful Links</h2>
<ul>
<li><a href="http://silverstripe.org">Get it</a></li>
<li><a href="http://addons.silverstripe.org">Get extra bits</a></li>
<li><a href="https://doc.silverstripe.org">Learn it</a></li>
<li><a href="http://api.silverstripe.org">Learn it better</a></li>
<li><a href="http://irc.silverstripe.org">Get help (possibly)</a></li>
<li><a href="http://github.com/silverstripe">Get the bleeding edge</a></li>
<li><a href="http://silverstripe.org/blog">Get news & opinions on it</a></li>
</ul>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
theme: Reveal.getQueryHash().theme,
transition: Reveal.getQueryHash().transition || 'default',
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>