Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
An Introduction to Symfony2
Search
Geoffrey Tran
July 03, 2012
Programming
1
210
An Introduction to Symfony2
A simple introduction to Symfony2 for LoneStarPHP11
Geoffrey Tran
July 03, 2012
Tweet
Share
More Decks by Geoffrey Tran
See All by Geoffrey Tran
Stop Exposing Yourself: Exploits, Attacks and Defenses
geoff
2
400
Other Decks in Programming
See All in Programming
functionalなアプローチで動的要素を排除する
ryopeko
1
200
Findy Team+ Awardを受賞したかった!ベストプラクティス応募内容をふりかえり、開発生産性向上もふりかえる / Findy Team Plus Award BestPractice and DPE Retrospective 2024
honyanya
0
140
Beyond ORM
77web
11
1.6k
Package Traits
ikesyo
1
210
『改訂新版 良いコード/悪いコードで学ぶ設計入門』活用方法−爆速でスキルアップする!効果的な学習アプローチ / effective-learning-of-good-code
minodriven
28
4.1k
ドメインイベント増えすぎ問題
h0r15h0
2
560
Jaspr Dart Web Framework 박제창 @Devfest 2024
itsmedreamwalker
0
150
선언형 UI에서의 상태관리
l2hyunwoo
0
270
asdf-ecspresso作って 友達が増えた話 / Fujiwara Tech Conference 2025
koluku
0
1.4k
技術的負債と向き合うカイゼン活動を1年続けて分かった "持続可能" なプロダクト開発
yuichiro_serita
0
300
Azure AI Foundryのご紹介
qt_luigi
1
200
php-conference-japan-2024
tasuku43
0
430
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
Facilitating Awesome Meetings
lara
51
6.2k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7.1k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.4k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.5k
jQuery: Nuts, Bolts and Bling
dougneiner
62
7.6k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Bash Introduction
62gerente
610
210k
Building Adaptive Systems
keathley
38
2.4k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Transcript
!Symfony2:!It’s!Play!Time! @geoffreytran! www.linkedin.com/in/geoffreytran!
What!is!Symfony2?! It!simply!solves!your!difficult!redundant!problems! …!and!gets!out!of!your!way!
You!are!not!boxed!in…!
…!easy!to!get!started,!yet!powerful!and!flexible!for! advanced!users!
Pre!Zend_ApplicaNon!Bootstrap! Index.php!
Post!Zend_ApplicaNon! Index.php!
“The core architecture is now stable…” – Fabien Potencier hPp://symfony.com/blog/symfony2QfinalQversionQweQareQnotQthereQyet!
In!development!since!December!2009!
A!lot!can!happen! in!a!year! A"baby?"
None
Top"2%"of"projects"on"Ohloh"
325"Bundles"Published" h>p://symfony2bundles.org/"
What!exactly!is!a!bundle?! A!bundle!is!like!a!plugin! …!except!Symfony2!itself!is!made!up!of!bundles!
“I!was!using!the!same!idea!by!organizing!my!code!in![zend!framework]! modules,!but!this!is!really!painful”! QQ!tawfekov!via!StackOverflow! ! hPp://stackoverflow.com/quesNons/5053369/doQyouQthinkQzendQframeworkQmissesQtheQsymfonysQbundleQprinciple!
Nothing!like!Symfony1!
Less!Magic! config_autoload.yml.php!
Explicit!ConfiguraNon! app/AppKernel.php!
Doctrine2! Doctrine2:!User.php! Doctrine!1.2:!User.php!
Decoupled!design!
None
None
None
None
What makes up Symfony2? ConfiguraNon! Kernel! Directory! Structure! Symfony!Framework!Bundles! Symfony!Components!
Getting started with Symfony2 distributions Similar!to!Linux!distribuNons!
hPp://symfony.com/download!
#!cd!~/Projects/LoneStarPHP! #!tar!xvzf!/path/to/Symfony_Standard_Vendors_2.0.0BETA4.tgz! Extract to your web directory
Check requirements hPp://yourhost/LoneStarPHP/web/config.php! Not!accessing!from!localhost?!! Remove!the!security!check! from:! web/config.php" web/app_dev.php"
Check requirements hPp://yourhost/LoneStarPHP/web/config.php!
Check requirements hPp://yourhost/LoneStarPHP/web/config.php!
Check requirements hPp://yourhost/LoneStarPHP/web/config.php!
Check requirements hPp://yourhost/LoneStarPHP/web/config.php!
Configure the database connection hPp://yourhost/LoneStarPHP/web/app_dev.php/_configurator/step/0! You!can!write!your! own!configuraNon! files!instead!
Yay, Welcome to Symfony! hPp://yourhost/LoneStarPHP/web/app_dev.php!
What!makes!a!page?! /hello/world" A!Route! !/hello/{name}" A!Controller! !A!PHP!funcNon! A!Response! !“<h1>Hello!World!</h1>”!
Step!1:!Create!a!route! /hello/world" File:"app/config/rouKng.yml" ! ! *!RouNng!can!also!be!defined!with!XML,!PHP!and!as!annotaNons! AcmeDemoBundle:LoneStar:hello!! maps!to! !Acme\DemoBundle\Controller\LoneStarController::helloAcNon()!
Step!2:!Create!a!controller! /hello/world" File:"src/Acme/DemoBundle/Controller/LoneStarController.php" ! ! *!At!its!simplest,!a!controller!is!just!a!funcNon!
Step!2:!Create!a!controller! /hello/world" File:"src/Acme/DemoBundle/Controller/LoneStarController.php" ! ! File:"app/config/rouKng.yml" ! !
/hello/world! hPp://yourhost/LoneStarPHP/web/app_dev.php/hello/world!
Great…!! But!HTML!in!controllers?!&@*$%!""
Meet!Twig" hPp://www.twigQproject.org! src/Acme/DemoBundle/Resources/views/LoneStar/hello.html.twig! src/Acme/DemoBundle/Controller/LoneStarController.php!
Hello!World!" hPp://yourhost/LoneStarPHP/web/app_dev.php/hello/world!
Digging!Deeper" hPp://yourhost/LoneStarPHP/web/app_dev.php/hello/world!
Digging!Deeper" hPp://yourhost/LoneStarPHP/web/app_dev.php/hello/world!
Do!less!work! /hello/world" File:"src/Acme/DemoBundle/Controller/LoneStarController.php" ! !
Give"it"a"try…"