Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Frameworks da Nova Era PHP

Dan Jesus
November 29, 2013

Frameworks da Nova Era PHP

Palestra aprensentada na PHPConference

Dan Jesus

November 29, 2013
Tweet

More Decks by Dan Jesus

Other Decks in Programming

Transcript

  1. 40#3&.*. $danjesus = [ “developer” => [“php”, js”, “ruby”, “java”,

    “objective-c”], “where” => [“LQDI Digital”, “Co-founder Solhys Tecnologia”], “blog” => [“danjesus.github.io”] ]; ! return $danjesus;
  2. criando um controller PJMHFOFSBUF DPOUSPMMFS\BDUJPOT^ oil generate controller Posts index

    view add criando um model PJMHFOFSBUF NPEFM oil generate controller Post index view add
  3. scaffolding criando automaticamente PJMHFOFSBUF TDB⒎PME oil generate scaffold Post title:varchar[200]

    content:text migrations PJMHFOFSBUFNJHSBUJPO\OBNF^ oil generate migration add_image_to_post image:varchar[200]
  4. class Controller_Posts extends Controller {} class Controller_Posts extends Controller_Template {}

    class Controller_Posts extends Controller_Rest {} class Controller_Posts extends Controller_Hybrid {} #"4& 5&.1-"5& 3&45 ):#3*%
  5. &4536563"$0/530--&3 class Controller_Posts extends Controller { ! public function action_index()

    { return Response::forge(View::forge('posts/index')); } ! } 1SFpYP$POUSPMMFS@QPEFTFSBMUFSBEPOBT DPOpHVSBÇÕFTQBSBVTBSVNOBNFTQBDF
  6. &4536563"$0/530--&3 class Controller_Posts extends Controller { ! public function action_index()

    { return Response::forge(View::forge('posts/index')); } ! } 5JQPEPDPOUSPMMFS
  7. &4536563"$0/530--&3 class Controller_Posts extends Controller { ! public function action_index()

    { return Response::forge(View::forge('posts/index')); } ! } BDUJPOQPEFSVNWFSCPIUUQDPNPHFU  QPTU QVU EFMFUF
  8. $0/530--&35&.1-"5& class Controller_Posts extends Controller_Template { //default template.php $this->template =

    'template-name'; ! public function action_index() { $this->template->title = 'Template Controller'; $this->template->content = View::forge('posts/index'); } }
  9. $0/530--&35&.1-"5& class Controller_Posts extends Controller_Template { //default template.php $this->template =

    'template-name'; ! public function action_index() { $this->template->title = 'Template Controller'; $this->template->content = View::forge('posts/index'); } } 1FSNJUFBQBTTBHFNEFWBSJÂWFJTFWJFXT QBSBPUFNQMBUF
  10. $0/530--&35&.1-"5& class Controller_Posts extends Controller_Template { //default template.php $this->template =

    'template-name'; ! public function action_index() { $this->template->title = 'Template Controller'; $this->template->content = View::forge('posts/index'); } } 7JFXRVFTFSÂSFOEFSJ[BEBEFOUSPEFTUB ÂSFBOPUFNQMBUF
  11. $0/530--&35&.1-"5& class Controller_Posts extends Controller_Template { //default template.php $this->template =

    'template-name'; ! public function action_index() { $this->template->title = 'Template Controller'; $this->template->content = View::forge('posts/index'); } } 7JFXRVFTFSÂSFOEFSJ[BEBEFOUSPEFTUB ÂSFBOPUFNQMBUF
  12. $0/530--&33&45 class Controller_Test extends Controller_Rest { protected $format = 'json';

    ! public function get_list() { return $this->response(array( 'foo' => Input::get('foo'), 'baz' => array( 1, 50, 219 ), 'empty' => null )); } }
  13. $0/530--&33&45 class Controller_Test extends Controller_Rest { protected $format = 'json';

    ! public function get_list() { return $this->response(array( 'foo' => Input::get('foo'), 'baz' => array( 1, 50, 219 ), 'empty' => null )); } } 'PSNBUPQPEFTFSKTPO YNM DTW IUNM QIQ PVTFSJBMJ[F
  14. $0/530--&33&45 class Controller_Test extends Controller_Rest { protected $format = 'json';

    ! public function get_list() { return $this->response(array( 'foo' => Input::get('foo'), 'baz' => array( 1, 50, 219 ), 'empty' => null )); } } BDUJPOQPEFTFSHFU QPTU QVU EFMFUFPV QBUDI
  15. $0/530--&3):#3*% class Controller_Post extends Controller_Hybrid { protected $format = 'json';

    ! public function action_index() { $this->template->content = View::forge('posts/index'); } ! public function get_list() { return $this->response(array( 'foo' => Input::get('foo'), 'baz' => array( 1, 50, 219 ), 'empty' => null )); } }
  16. namespace Model; ! class Welcome extends \Model { ! public

    static function get_results() { // Interações com o banco de dados } ! }
  17. namespace Model; ! class User extends \Model_Crud { protected static

    $_properties = array( 'id', 'name', 'age', 'birth_date', 'gender', ); ! protected static $_table_name = 'users'; } .0%&-$36%
  18. namespace Model; ! use Orm\Model; ! class User extends Model

    { protected static $_properties = array( 'id', 'name', ); ! protected static $_table_name = 'users'; ! protected $_observers; protected $_belongs_to; protected $_has_many; protected $_has_one; protected $_many_many; } 03.
  19. $view = View::forge('path/to/view', array( 'menu' => $menu, 'articles' => $articles,

    'footer_links' => $footer_links, ))->auto_filter(); ! return $view;
  20. arquivo developement/db.php return array( 'default' => array( 'connection' => array(

    'dsn' => 'mysql:host=localhost;dbname=fuel_dev', 'username' => 'root', 'password' => 'root', ), ! 'profilling' => true ), ); $POpHVSBÇÄPEPCBODPEFEBEPT
  21. arquivo routes.php return array( '_root_' => 'welcome/index', // The default

    route '_404_' => 'welcome/404', // The main 404 route 'hello(/:name)?' => array('welcome/hello', 'name' => 'hello'), );
  22. public static function validate($factory) { $val = Validation::forge($factory); $val->add_field('title', 'Title',

    'required|max_length[50]'); $val->add_field('content', 'Content', 'required'); ! return $val; } Validações no model