2. Aim
• Present symfony in an original way
• Make an application in one hour
vendredi 13 novembre 2009 2
3. Who am I?
• Philippe Gamache
•PHP security expert at
Parler Haut, Interagir
Librement
•Author of the book
« Sécurité PHP 5 et MySQL »
with Damien Seguy, at
Eyrolles
•http://www.ph-il.ca
•http://www.phportail.net
•http://lapageamelkor.org
•naheulbeukauquebec.ca
vendredi 13 novembre 2009 3
4. Questions?
?
Please wait at the
end, we don’t
have much time
vendredi 13 novembre 2009 4
5. The application
• Blog
• Comments
• Clean URLs
vendredi 13 novembre 2009 5
6. Install symfony
http://www.symfony-project.org/installation
• Source
• Sandbox
• PEAR
• SVN
• Linux Package (Debian and SUSE)
vendredi 13 novembre 2009 6
7. Install using PEAR
pear channel-discover pear.symfony-project.com
pear install symfony/symfony-1.2.4
vendredi 13 novembre 2009 7
8. Create the project
• Create directory project
$ mkdir -p blog
$ cd blog
• Check symfony’s version
$ symfony -V
• Create project
$ symfony generate:project blog
vendredi 13 novembre 2009 8
9. Create the project
• Create an application
$ symfony generate:app /
--escaping-strategy=on /
--csrf-secret=Unique$ecr3t1 /
frontend
• Adjust your web server
vendredi 13 novembre 2009 9
17. Database fixtures
BlogPost:
post_1:
Author: philippeg
title: Lorem ipsum dolor sit amet
content: |
<p>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut...</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do...</p>
is_published: true
published_at: 09-01-07
post_2:
Author: philippeg
title: Ut enim ad minim veniam
content: |
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse...</p>
is_published: true
published_at: 09-01-07
post_3:
Author: philippeg
title: Duis aute irure dolor in reprehenderit in voluptate
content: |
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse...</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
is_published: true
published_at: 09-01-07
...
vendredi 13 novembre 2009 17
18. Database fixtures
BlogComment:
comment_1:
BlogPost: post_1
author_name: lorem
content: Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat.
comment_2:
BlogPost: post_1
author_name: elit
content: Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
comment_3:
BlogPost: post_3
author_name: aute
content: Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.
comment_4:
BlogPost: post_3
author_name: aute
content: ESunt in culpa qui officia deserunt mollit anim id est laborum.
vendredi 13 novembre 2009 18
19. Create the tables
• Create the tables and load all fixtures
$ symfony doctrine:build-all-load
vendredi 13 novembre 2009 19
20. Creating the code
• Use the code generator
$ symfony doctrine:generate-crud /
--with-show frontend post BlogPost
• Delete unnecessary actions
• executeNew()
• executeEdit()
• executeUpdate()
• executeDelete()
• processForm()
vendredi 13 novembre 2009 20
21. Creating the code
• Delete unnecessary files
• templates/_form.php
• templates/editSuccess.php
• templates/newSuccess.php
• Clear links to other functions
vendredi 13 novembre 2009 21
43. Backend creation
• Edit myUser.class.php
class myUser extends sfGuardSecurityUser
{
}
vendredi 13 novembre 2009 43
44. To go further
• Add tags
• Add a mini-calendar
• Display posts per month
• Add search
• Add feeds (RSS, ATOM) via
sfFeed2plugins
vendredi 13 novembre 2009 44