-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
813 lines (655 loc) · 23.4 KB
/
index.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
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Breathing fire with FuelPHP</title>
<meta name="description" content="A quick presentation slideshow of the best parts of this awesome new framework">
<meta name="author" content="Hakim El Hattab">
<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/default.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', use the PDF print sheet -->
<script>
document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="slides">
<section data-markdown data-background="img/fuelphp-bg.png">
<script type="text/template">
# Breathing fire with FuelPHP
PHP is getting Awesome.
</script>
</section>
<section data-markdown>
<script type="text/template">
# The guy talking
``` basic
10 PRINT "This RULES!"
20 GOTO 10
```
* It all started with Basic *(in highschool)*
* Learned PHP *myself* to build automotive sites
* Digital Media & CS from UCF
* Lead a **rad** team at [The Center for Distributed Learning](http://online.ucf.edu/)
* Build stuff like: [Obojobo](http://obojobo.ucf.edu), [Materia](http://materia.ucf.edu), and [HowTune](http://howtune.com)
<br/>
## <span style="color:#999;">In one word:</span> Inspired.
<small>more? [ianturgeon.com](http://ianturgeon.com)</small>
</script>
</section>
<section data-markdown>
<script type="text/template">
# Modern PHP
FuelPHP **requires** PHP 5.3
* Object oriented everything
* Heavy use of Namespaces
* No PEAR (gross), more Composer (yay)
* Templates are better with short tags <?= $user ?>
* PHP 5.4 has a built in server!
</script>
</section>
<section data-markdown>
<script type="text/template">
# The Good Parts
* Hierarchical MVC
* Understandable request routing.
* Active Record ORM.
* RESTful Controllers.
* Command line utility that will perform Magic.
</script>
</section>
<section data-markdown>
<script type="text/template">
# Hierarchial Model View Controller
* MVC. a popular design pattern
* Seperate logic, data, and display.
* Hierarchical design lets you extend everything.
* FuelPHP adds ViewModels; Remove view logic from your controller.
</script>
</section>
<section>
<section data-markdown>
<script type="text/template">
# Models
### Model your data in Object Oriented Form.
* Models handle data, and interaction with that data
* True Active Record implementation (from Rails)
* Define relationships between models
* Bypass the magic any time, build queries manually.
</script>
</section>
<section data-markdown>
<script type="text/template">
# Models
## A Basic Model Class
```php
class Model_Car extends \Orm\Model
{
protected static $_properties = [
'make',
'model',
'year',
'created_at',
'updated_at'
];
public function get_name()
{
return "{$this->year} {$this->make} {$this->model}";
}
}
```
<small>fuel/app/classes/model/car.php</small>
</script>
</section>
<section data-markdown>
<script type="text/template">
# Finding Models
```php
// find one by id
Model_Car::find(1);
// find all my make
$cars = Model_Car::find()->where('make', 'Scion')->get();
// find one my make
$one_car = Model_Car::find()->where('make', 'Scion')->get_one();
// fall back to a database query
$cars = DB::select()
->from('cars')
->where('make', 'Scion')
->as_object('Model_Car')
->execute();
```
</script>
</section>
<section data-markdown>
<script type="text/template">
# Relating Models
```php
class Model_User extends \Orm\Model
{
protected static $_belongs_to = [
'car'
];
}
```
```php
class Model_Car extends \Orm\Model
{
protected static $_has_one = [
'user'
];
}
```
```php
$car = Model_Car::find(1);
$car->user
```
User is automatically retrieved from the database!
</script>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
# Views
* Think of it as presentation **filter**.
* Used to display models.
* No application logic. **None**.
* Can be an entire web page
* Or just partials of a page
</script>
</section>
<section data-markdown>
<script type="text/template">
<h1>Example View</h1>
```
<!doctype html>
<html>
<head>
<title><?php echo $car_name; ?></title>
<head>
<body>
<h1>Displaying: <?php echo $car_name; ?></h1>
</body>
</html>
```
<small>fuel/app/views/car_template.php</small>
</script>
</section>
<section data-markdown>
<script type="text/template">
# Tons of Options
Support for many template engines using Parser package.
* Dwoo
* Haml
* Jade
* Markdown
* Mustache
* Simpletags
* Smarty
* Twig
</script>
</section>
<section data-markdown>
<script type="text/template">
# Mustache Views
```
<!doctype html>
<html>
<head>
<title>{{car_name}}</title>
<head
<body>
<h1>Displaying: {{car_name}}</h1>
</body>
</html>
```
<small>fuel/app/views/car_template.mustache</small>
</script>
</section>
<section data-markdown>
<script type="text/template">
# Jade Views
```jade
!!!5
html
head
title {{ $car_name }} Detailst;
body
h1 Displaying: {{ $car_name }}
```
<small>fuel/app/views/car_template.jade</small>
</script>
</section>
<section data-markdown>
<script type="text/template">
<h1>Using a View</h1>
passing variables to the view
```php
$data = array();
$data['car_name'] = $car_name;
$view = View::forge('car_template', $data);
```
<small>(this happens in a controller)</small>
</script>
</section>
<section data-markdown>
<script type="text/template">
# Using a view
more complex options
```php
// using set
$view = View::forge('car_template');
$view->set('car_name', $car->name);
// using Jade
$view = View::forge('car_template.jade');
// using nested partial views
$partial = View::forge('partials/car.jade');
$page = View::forge('page_template.jade');
$page->set_safe('content', $partial);
```
<small>* View::set() scrubs html entities, set_safe() bypasses this security filter</small>
</script>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
# Controllers
* The link betwen users and the system
* Controllers respond to requests (accepting input)
* They orchistrate actions upon the models
* Then they arrange views
</script>
</section>
<section data-markdown>
<script type="text/template">
# Basic Controllers
```php
class Controller_Car extends Controller
{
// url: site/car/view/10
public function action_view($car_id)
{
// find car
// display car
}
}
```
<small>fuel/app/classes/controller/car.php</small>
</script>
</section>
<section data-markdown>
<script type="text/template">
# Template Controllers
```php
class Controller_Car extends Controller_Template
{
// set template to fuel/app/views/car_template.php
public $template = 'car_template';
public function action_view($car_id)
{
// find car
$this->template->car_name = $car->name;
}
}
```
<small>fuel/app/classes/controller/car.php</small>
</script>
</section>
<section data-markdown>
<script type="text/template">
# Rest Controllers
```php
class Controller_Car extends Controller_Rest
{
// request: GET site/car/single/1
public function get_single($id)
{
// find car
return $car;
}
// request: POST site/car/single
public function post_single()
{
// get the POSTed car data
// save the car
return $car;
}
}
```
<small>fuel/app/classes/controller/car.php</small>
</script>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
# Routing
* How FuelPHP responds to user requests
* Works automatically w/ Built in Auto-Magic
* Use regex for **Very Flexible** url matching.
</script>
</section>
<section data-markdown>
<script type="text/template">
# Auto-Magical Routing
All public actions are accessible.
```php
class Controller_Car extends Controller
{
// http://site.com/car
public function action_index(){}
// http://site.com/car/view
public function action_view(){}
// http://site.com/car/edit
public function action_edit(){}
}
```
<small>fuel/app/classes/controller/car.php</small>
</script>
</section>
<section data-markdown>
<script type="text/template">
# Directory Structures
FuelPHP uses controller directories for routing.
```php
class Controller_Car extends Controller
{
// site.com/car/sell
public function action_sell(){}
}
```
<small>fuel/app/classes/controller/car.php</small>
```php
class Controller_Api_Car extends Controller
{
// site.com/car/api/sell
public function action_sell(){}
}
```
<small>fuel/app/classes/controller/api/car.php</small>
</script>
</section>
<section data-markdown>
<script type="text/template">
# Passing a Variable
Auto-magic supports a single argument.
```php
class Controller_Car extends Controller
{
// site.com/car/view/1
public function action_view($car_id){}
// site.com/car/edit/4
public function action_edit($car_id){}
}
```
<small>fuel/app/classes/controller/car.php</small>
</script>
</section>
<section data-markdown>
<script type="text/template">
# Advanced Routing
Override defaults and respond to complex requests
```php
return [
'_root_' => 'site/index', // The default route
'_404_' => 'site/404', // The main 404 route
// From: http://site.com/vehicles/4/like
// To: Controller_Cars::action_like($car_id)
// $car_id is "4"
'vehicles/:car_id/like' => 'cars/like/$1',
// From: http://site.com/vehicles/10/photos/20
// To: Controller_Photos::action_view($car_id, $photo_id)
// $car_id is "10" and $photo_id is "20"
'vehicles/:car_id/photos/:id' => 'photos/view/$1$2'
];
```
<small>fuel/app/config/routes.php</small>
</script>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
# Oil
## <span style="color:rgb(115, 100,125);">Generate</span> builds code
## <span style="color:rgb(115, 100,125);">Refine</span> executes code
A **command line** utility that writes and execute code.
```bash
$ php oil refine migrate
$ php oil r migrate
$ php oil generate model car name:string
$ php oil g model car name:string
```
</script>
</section>
<section data-markdown>
<script type="text/template">
# Migrations
## Build and execute database changes
```bash
$ php oil refine migrate
```
Oil will figure out which migration you are currently on, and run any newer ones.
</script>
</section>
<section data-markdown>
<script type="text/template">
# Generate Everything
## Scaffolding
```bash
$ php oil generate scaffold car name:string make:string model:string
```
### Instantly builds:
1. **Model**: app/classes/model/car.php
2. **Migration**: app/migration/001_create_car.php
3. **Controller**: app/classes/controller/car.php
4. **5 Views**: app/views/cars/index, view, create, edit, _form
</script>
</section>
<section data-markdown>
<script type="text/template">
# One Part at a Time
## Generate
```bash
$ php oil g model cars make:string model:string
$ php oil g controller cars
$ php oil g migration rename_table_cars_to_vehicles
$ php oil g task mytask
$ php oil g config mypackage
```
</script>
</section>
<section data-markdown>
<script type="text/template">
# Run Tasks
## Maintinance and Installation
```bash
$ php oil r install
$ php oil r admin:create_user iturgeon ian turgeon [email protected]
$ php oil r cars:delete_car 4
```
</script>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
# Pro Tips
</script>
</section>
<section data-markdown>
<script type="text/template">
# Learn The Documentation
[docs.fuelphp.com](http://docs.fuelphp.com)
</script>
</section>
<section data-markdown>
<script type="text/template">
# Filenames Matter
```
// classes/controller/cars.php
class Controller_Cars {}
// classes/controller/assets/cars.php
class Controller_Assets_Cars {}
// classes/model/cars.php
class Model_Cars {}
```
</script>
</section>
<section data-markdown>
<script type="text/template">
# Configuration
Environment configs let you change options.
```php
'base_url' => 'http://site.com',
```
<small>config/my_config.php</small>
```php
'base_url' => 'http://dev.site.com',
```
<small>config/development/my_config.php</small>
Environments: development, production, staging, and test
</script>
</section>
<section data-markdown>
<script type="text/template">
# Migration Status
### Migration status is kept in **2** places.
* **The Database** (table: *migration*).
* **Environment Config** (*config/development/migration.php*)
<br>
When moving and re-installing your app, migrations can get confused. Do not move or commit your migration config.
</script>
</section>
<section data-markdown>
<script type="text/template">
# ORM Relationships
## Here are the rules:
* **Belongs To**: *has primary key from other table*
* **Has One**: *other table has my primary key*
* **Has many**: *many in other table have my primary key*
* **Many to Many**: *a relational table holds both primary keys*
<br>
Never rely on the english, it can be thought of in either direction.
</script>
</section>
<section data-markdown>
<script type="text/template">
# PHP Method Chaining
```php
Model_Car::find(1)
->set('make', 'Scion')
->set('model', 'FR-S')
->save();
View::forge('template')
->set('title', 'Vehicle Name')
->set('content', View::forge('partials/car')
->set('car', Model_Car::find(1)
)
);
```
</script>
</section>
<section data-markdown>
<script type="text/template">
# Use Query Builder
Abstracts your database calls, and scrubs your input.
```php
DB::select()
->from('cars')
->join('owners')
->on('cars.id', '=', 'owners.car_id')
->where('make', $make_search)
->order_by('make')
->execute();
```
</script>
</section>
<section data-markdown>
<script type="text/template">
# Short Tags
## Minimize your templates
```
<!doctype html>
<html>
<head>
<title><?php echo $car_name; ?></title>
<title><?= $car_name ?></title>
<head>
<body>
<h1>Displaying: <?php echo $car_name; ?></h1>
<h1>Displaying: <?= $car_name ?></h1>
</body>
</html>
```
Short tags are on by default in php 5.4
</script>
</section>
</section>
<section data-markdown >
<script type="text/template">
PHP **IS** Getting Awesome.
<small>[FuelPHP Crash Course](http://ucf.github.io/fuelphp-crash-course/)</small>
</script>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script type="text/javascript">
Reveal.initialize({
// Display controls in the bottom right corner
controls: true,
// Display a presentation progress bar
progress: true,
// Push each slide change to the browser history
history: true,
// Enable keyboard shortcuts for navigation
keyboard: true,
// Enable the slide overview mode
overview: true,
// Vertical centering of slides
center: true,
// Loop the presentation
loop: false,
// Change the presentation direction to be RTL
rtl: false,
// Number of milliseconds between automatically proceeding to the
// next slide, disabled when set to 0, this value can be overwritten
// by using a data-autoslide attribute on your slides
autoSlide: 0,
// Enable slide navigation via mouse wheel
mouseWheel: false,
// Apply a 3D roll to links on hover
rollingLinks: true,
// Transition style
transition: 'default', // default/cube/page/concave/zoom/linear/fade/none
// Transition speed
transitionSpeed: 'default', // default/fast/slow
// Transition style for full page backgrounds
backgroundTransition: 'slide', // default/linear
// Optional libraries used to extend on reveal.js
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; } }
// { src: 'plugin/search/search.js', async: true, condition: function() { return !!document.body.classList; } }
{ src: 'plugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>