Word Camp Kansai 2014 - MVC Framework

2,757 views
2,612 views

Published on

Notes from my presentation at Word Camp Kansai 2014. Be sure to visit http://codebyjeff.com/blog/2014/03/make-your-own-wordpress-mvc-plugin as well for a tutorial on creating this yourself

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

No Downloads
Views
Total views
2,757
On SlideShare
0
From Embeds
0
Number of Embeds
1,682
Actions
Shares
0
Downloads
3
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Word Camp Kansai 2014 - MVC Framework

  1. 1. WordPress を MVC フレームワーク として使用する
  2. 2. Who? What? Why? Where? How?
  3. 3. Who? What? Why? Where? How?
  4. 4. Jeff Madsen @codebyjeff Lead Developer, Alyte Creative (Australia)
  5. 5. YOU! 中級レベルな プログラムマー
  6. 6. Who? What? Why? Where? How?
  7. 7. http://localhost/usertut/test
  8. 8. No pages found!
  9. 9. MVC フレームワーク プラグイン
  10. 10. M - Model V - View C - Controller ex: Codeigniter, CakePhp, Rails, Django
  11. 11. コード の編成 Code Organization
  12. 12. これもう一回見たことがある か?
  13. 13. もう アカン!
  14. 14. Who? What? Why? Where? How?
  15. 15. build pages with git/deployment tools
  16. 16. use Composer.org libraries
  17. 17. TESTABLE!!
  18. 18. Who? What? Why? Where? How?
  19. 19. MU-PLUGINS #1 最初 loading (plugins もう大丈夫 )
  20. 20. Who? What? Why? Where? How?
  21. 21. What do we need? Router  ( ディスパッ チ ) Custom post types class Views Libraries
  22. 22. WP-Router (https://wordpress.org/plugins/ wp-router/)
  23. 23. Custom Post Type Class http://github.com/ jjgrainger/ wp-custom-post-type- class/
  24. 24. PlatesPHP (http://platesphp.com/) -similar to Twig -framework agnostic Plates
  25. 25. Composer (http://getcomposer.org)
  26. 26. Structure Similar to CodeIgniter CakePHP Rails
  27. 27. loader.php require_once( 'alyte-core/system/plugin.php' ); require_once('alyte-core/vendor/autoload.php'); ... system/plugin.php //load the core classes, scripts add_action( 'plugins_loaded', 'alyte_plugins_loaded' ); add_action( 'wp_enqueue_styles', 'alyte_load_styles' ); add_action( 'wp_enqueue_scripts', 'alyte_load_scripts' ); ... call the bootstrap.php ...
  28. 28. static function show_student_profile( $router ) { $args = array( 'path' => '^profile/(.*?)$', 'query_vars' => array( 'user_id' => 1, ), 'page_callback' => array( 'Alyte_Students','get' ), 'page_arguments' => array('user_id'), 'access_callback' => true, 'title' => 'Your Student Profile', 'template' => array('page.php', dirname(__FILE__).DIRECTORY_SEPARATOR.'page.php') ); $router->add_route( 'show-student-profile-route', $args ); } MAGIC HAPPENS HERE class-routes.php
  29. 29. Student Class static function get($id) { $user = new User($id); $data = array( 'id' =>$id, 'user' => $user, ); // Plates PHP $template = self::make_template(); $template->data($data); return $template->render('students/profile_view'); }
  30. 30. View
  31. 31. Page

×