Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Slim RedBeanPHP and Knockout

3,642 views

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
  • Be the first to comment

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/

×