Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Laravel5.1をつかった Webアプリケーション開発
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
kan
February 17, 2016
Programming
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Laravel5.1をつかった Webアプリケーション開発
いまどきのPHPフレームワークは、こんなことになってるよ
kan
February 17, 2016
More Decks by kan
See All by kan
Androidアプリ開発にクリーンアーキテクチャを取り入れよう(OSS編)
notice
0
180
Androidアプリ開発にクリーンアーキテクチャを取り入れよう
notice
0
680
Other Decks in Programming
See All in Programming
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
360
AI-Powered Domain-Driven Design
ziobrando
0
380
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
1
2k
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
220
Spec-Driven Development - Why Vaadin Is the Perfect Fit
simas
PRO
0
220
SODA - FACT BOOK(JP)
sodainc
1
40k
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
3
1.4k
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
200
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
150
Next.js: The final boss of Web Performance
guaca
0
380
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
400
No More NoSuchMethodError
exoego
1
120
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
390
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
290
Building AI with AI
inesmontani
PRO
1
1.4k
Ethics towards AI in product and experience design
skipperchong
2
460
Making the Leap to Tech Lead
cromwellryan
135
10k
Leo the Paperboy
mayatellez
10
2.4k
Amusing Abliteration
ianozsvald
1
380
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Transcript
いまどきのPHPフレームワークは、 こんなことになってるよ Laravel5.1をつかった Webアプリケーション開発 2015/08/20
[email protected]
http://www.notice.co.jp/ @notice_inc
お話しすること • フレームワーク・アーキテクチャ • Laravelの特徴 • Laravelのアプリケーション開発サイクル • ステージング環境構築 •
脆弱性検査とパフォーマンス検査 • CI
フレームワーク・アーキテクチャ • PofEAA (Patterns of Enterprise Application Architecture) • DDD(Domain
Driven Development) • GoF Design Patterns • (The Three Amigos, UML)
最近、話題のアーキテクチャ MicroService Architecture PofEAAの著者マーティン・ファウラー氏が提唱 こんな話も… http://www.slideshare.net/AkiraMiki/20160722-microservice PHP Micro frameworks こっちは小さい・シンプルって方
Lumen,Slim,Silex
Laravel5.1の特徴 • PHP >= 5.5.9 • LTS(Long Term Support) •
Composerによるパッケージ管理 • Symfony2コンポーネント継承 • IoCコンテナ装備 • データベースマイグレーション機能 • 強力なORM(Eloquent ORM) • Bladeテンプレートエンジン • gulpが標準タスクランナー(Elixir)
ベンチマーク 遅い、大食い… DIのせいかな?? 全てのサービスがリクエストごとにDI対象 しかし、 不必要なサービスを外すとか チューニングすれば、解消? PHP7/HHVM(JIT)とか使えばいっか!
アプリケーション開発サイクル 命名規則(CoC)とケーススタイル データベーステーブル、カラム名は スネークケーススタイル(hoge_fuga) テーブル名は複数形・モデルクラス名は単数形 PHPコーディングはPSR-2準拠(Laravel5.1準拠) メソッド・変数名は文脈で単数・複数形を使い分け CSSのid,classはチェインケーススタイル(hoge-fuga) ※CSSはSMACCSに準拠,CSSプリプロセッサはLess
アプリケーション開発サイクル Laravelインストール $ composer create-project laravel/laravel --prefer-dist $ cd laravel;
git init # とりあえずリポ作成 $ composer install # frameworkのダウンロード $ gulp # ビルド(transpile,minify,uglify CSS/Javascript) $ artisan serve # PHP buildin server起動(port:8000) create-project使うと、passwordハッシュのソルトとか自動生成してくれて便利 Javascript/CSSライブラリはbowerとnpmでパッケージ管理
アプリケーション開発サイクル データベースマイグレーション Schema Builderでテーブル定義を書く。 $ artisan make:migration create_users_table $ artisan
db:migrate 初期データの投入はseederを書く(モデルクラス定義後)。 $ artisan db:seed
アプリケーション開発サイクル 各テーブルのORMクラスを生成 $ artisan make:model User 関連もORMクラスに定義 hasOne(),hasMany(), belongsTo(),belongsToMany()... Lazy
Eager Loadingをサポート
アプリケーション開発サイクル URI設計とルーティング設定 URIとコントローラのメソッドを結びつける Route::get(‘/projects’, ‘ProjectController@index’); Route::get(‘/projects/{id}/show’, ‘ProjectController@show’); Pretty URLで記述できる。 middlewareと呼ばれるフィルタを自在に設定可能。
アプリケーション開発サイクル コントローラを書く コントローラの役目は、 (1)リクエストをバリデーション(バリデータをDIできる) (2)ビジネスロジックを実行 (3)表示に必要なデータをViewへ渡すまで。 コンストラクタでサービスの実装をDIする。 public function __construct(ServiceInterface
$service) fat controllerにしない。 ビジネスロジックはサービス層で、設計と実装を分離する。 UnitTestがしやすくなる。
アプリケーション開発サイクル PHPUnit Laravelのテスティングクラスでテストケースを記述 Webページのインタラクティブな動作も記述可能(visit,click,see) フレームワークのメソッドをMockできる(Mockery)。 未完成のサービスはDIでMockをbindする。 ファクトリを使ったテストデータ作成(Faker) データベースもテストケースごとにリセット可能(ロールバック)。 PsySHでインタラクティブなテストも可能 TDD(テストファースト)からBDD(スペックファースト)へ
開発とはオールレッドをオールグリーンに変えていく作業。
ステージング環境の構築 VirtualBox+Vagrantで プロダクション環境と 同じOS、ミドルウェアを構成管理 プロビジョニングはAnsibleを利用 デプロイメントもAnsibleを利用 ※デプロイメントスタイルはCapistranoスタイル QA(Quality Authroity)向けにも提供
脆弱性検査とパフォーマンス検査 Vaddy+New Relic どちらも無償版があるが、 実務では有償版でないと十分機能しないかも。
CI(Continuous Integration) Gitリポジトリのmasterへpush/mergeをトリガー ステージング環境をVagrant,Dockerで 一時的に構築しプロビジョニング Gitリポジトリからmasterをarchive/export ビルド ユニットテスト実行 (結果を通知 HipChat,Slackとかへ)
通過すれば、Vaddyで脆弱性検査 ステージング環境を破棄 プロダクション版リリース これらをCIで自動化したい。 TravisCI,Jenkins,CircleCI