Knockout.js
With Minimal PHP
by Vic Metcalfe
Minimal Framework

Slim is 3.2MB
Symfony is
50MB
Minimal Framework
<?php
$app = new SlimSlim();
$app->get('/hello/:name', function ($name) {
echo "Hello, $name";
});
$app-...
Minimal ORM

325K
B
RedBeanPHP is 8.8MB
Doctrine is 9.2MB
Minimal ORM
$post = R::dispense('post');
$post->text = 'Hello World';
$id = R::store($post);
//Create or Update
$post = R:...
Minimal JavaScript

Knockout is 46KB
Angular is 100KB
Minimal JavaScript
Symfony
Doctrine
Angular
No MVC

G
Sh
ou
ld

G
Sh
ou
ld

p

p

View
View

En
ds
U

sU
End

M odel
M odel

o

UI

o

Domain Logic

Controller
Contro...
Slim: Git R’ Done
Authentication?
Content Negotiation?
Middleware
Middleware

Massage Input Data?
Page
Generation!
Content...
Knockout: MVVM
Model
M odel

View
View

ViewModel
ViewM odel

How your PHP represents your data

HTML with data-bind attri...
The Demo
Knockout is Testable
JavaScript!

•

ViewModel must be a class

•

Sinon is helpful for testing AJAX
Slim is Testable!
•

Create your own App class

•

Create an invoke method:
public function invoke() {
$this->middleware[0...
RedBeanPHP is
almost Testable!
•

Use in-memory sqlite:
public function setUp()
{
R::setup('sqlite::memory:');
require('se...
Thanks Y’All!
•

Demo source available at:
https://github.com/zymsys/Slim-RedBeanPHP-KnockoutJS

•

I rarely tweet @v_metc...
Slim RedBeanPHP and Knockout
Upcoming SlideShare
Loading in …5
×

Slim RedBeanPHP and Knockout

2,781
-1

Published on

Slides from the talk at http://www.meetup.com/GTA-PHP-User-Group-Toronto/events/151672182/

Source code for the demo at https://github.com/zymsys/Slim-RedBeanPHP-KnockoutJS

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,781
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
20
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Slim RedBeanPHP and Knockout

  1. 1. Knockout.js With Minimal PHP by Vic Metcalfe
  2. 2. Minimal Framework Slim is 3.2MB Symfony is 50MB
  3. 3. Minimal Framework <?php $app = new SlimSlim(); $app->get('/hello/:name', function ($name) { echo "Hello, $name"; }); $app->run();
  4. 4. Minimal ORM 325K B RedBeanPHP is 8.8MB Doctrine is 9.2MB
  5. 5. Minimal ORM $post = R::dispense('post'); $post->text = 'Hello World'; $id = R::store($post); //Create or Update $post = R::load('post',$id); //Retrieve R::trash($post); //Delete
  6. 6. Minimal JavaScript Knockout is 46KB Angular is 100KB
  7. 7. Minimal JavaScript
  8. 8. Symfony Doctrine Angular
  9. 9. No MVC G Sh ou ld G Sh ou ld p p View View En ds U sU End M odel M odel o UI o Domain Logic Controller Controller
  10. 10. Slim: Git R’ Done Authentication? Content Negotiation? Middleware Middleware Massage Input Data? Page Generation! Content Negotiation? Decoration? Caching?
  11. 11. Knockout: MVVM Model M odel View View ViewModel ViewM odel How your PHP represents your data HTML with data-bind attributes Two way binding of data and UI
  12. 12. The Demo
  13. 13. Knockout is Testable JavaScript! • ViewModel must be a class • Sinon is helpful for testing AJAX
  14. 14. Slim is Testable! • Create your own App class • Create an invoke method: public function invoke() { $this->middleware[0]->call(); $this->response()->finalize(); return $this->response(); }
  15. 15. RedBeanPHP is almost Testable! • Use in-memory sqlite: public function setUp() { R::setup('sqlite::memory:'); require('seed.php'); } public function tearDown() { R::close(); }
  16. 16. Thanks Y’All! • Demo source available at: https://github.com/zymsys/Slim-RedBeanPHP-KnockoutJS • I rarely tweet @v_metcalfe • I even more rarely blog: http://blog.vicmetcalfe.com/

×