Advertisement

Laravel / Lumen 次の一歩

Programmer at istyle
May. 30, 2015
Advertisement

More Related Content

Viewers also liked(20)

Advertisement

Recently uploaded(20)

Advertisement

Laravel / Lumen 次の一歩

  1. Laravel / Lumen 次の一歩 ytake / 20150529 Laravel LT at JP
  2. Profile • ytake (github), ex_takezawa(twitter) • java, php, node.js, RDBMS, NoSQL, VoltDB
  3. 4章を担当させていただきました Containerなど盛り沢山
  4. Facade Really useful :)
  5. != GoF Facades
  6. Facadeを利用する上での問題 • static だと思ってしまう。(養成読本をどうぞ!) • 確かに楽ですが、テストコード正しく書けてま すか? • どこでも簡単に使えるので、
 非構造化になりがち
  7. Eloquentも同じ
  8. public function getEntries() { $entries = Entry::all() ->toArray(); if(!count($entries)) { throw new Exception; } }
  9. $eloquentMock = m::mock(‘overload:App RepositoriesEloquentEntry'); $collection = m::mock(‘Illuminate DatabaseEloquentCollection'); $eloquentMock ->shouldReceive(‘all') ->andReturn($collection); $collection->shouldReceive(‘toArray') ->andReturn([1, 2, 3]);
  10. 次のステップにいくには 構造化を考えることが大事
  11. インターフェース/疎結合
  12. インターフェース 具象クラス バインド
  13. インターフェース 具象クラス インターフェース 具象クラス インターフェース 具象クラス インターフェース 具象クラス インターフェース 具象クラス インターフェース 具象クラス コンテナ *イメージ
  14. コンストラクタ・メソッド インジェクションで解決
  15. HogeClass constructor 具象クラス インターフェース
  16. HogeClass hogeと名付けよう
 サービスロケータなど
  17. 名前 具象クラス 名前 具象クラス インターフェース 具象クラス インターフェース 具象クラス 名前 具象クラス インターフェース 具象クラス コンテナ *イメージ
  18. Facade 具象クラス インターフェース
 名前 *関連性にアクセスするためのもの
  19. // バインディング $this->app->bind( 'AppHogeable', 'AppHoge' ); // 関係性にアクセサ名 $this->app->bind('hoge', function() { return $this->app->make('AppHogeable'); });
  20. バインドの次は、 Facadeの実クラスを知ること よりテストがしやすく 補完にもやさしい
  21. DB => DatabaseManager
  22. Redirect => Redirector + UrlGenerator + RouteCollection
 + Request
  23. 概念も分離
  24. DB リポジトリ エンティティ Eloquent / ORM
  25. ストレージ リポジトリ DBに依存してはならない
  26. HogeClass リポジトリ サービス I/F I/F
  27. Route formRequest Controller before
 middleware after
 middleware view
  28. Route formRequest Controller before
 after
 view サービス I/F リポジトリ I/F dispatch
  29. 分離することで見えてくる
 フレームワーク
  30. 本当のLaravelはここから
  31. ご静聴ありがとうございました
Advertisement