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
Jakarta EE meets AI
ivargrimstad
0
640
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
24k
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
140
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
230
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
[Do iOS '24] Ship your app on a Friday...and enjoy your weekend!
polpielladev
0
110
CSC509 Lecture 13
javiergs
PRO
0
110
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
940
Jakarta EE meets AI
ivargrimstad
0
190
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
880
as(型アサーション)を書く前にできること
marokanatani
10
2.7k
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
How GitHub (no longer) Works
holman
310
140k
Side Projects
sachag
452
42k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Embracing the Ebb and Flow
colly
84
4.5k
Become a Pro
speakerdeck
PRO
25
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…"