
Symfony is an open source web application framework for PHP5 projects. As a framework, it aims to speed up the creation and maintenance of web applications, and to replace the repetitive coding tasks by power, control and pleasure.
Main features
- PHP5 (OO)
- MVC pattern
- Follows the RAD paradigm
- Database agnostic
- ORM layer built on propel
- Internationalization layer
- YAML config files
- Built-in forms validation/repopulation
- Cache management
- Authentication and credential features
- URL rewriting
- Built-in paging, sorting and filtering features
- Plug-ins system
- Ajax ready
The purpose here is not to replace the very complete documentation of Symfony. It's just a kind of "roadmap summary" of what I'have done until now with Symfony.
Installation
Thanks to the large documentation of Symfony, the installation has been very easy on my Linux Gentoo (PHP 5.2.1):
1. Install Symfony core
As I can't use pear on my server, I downloaded the latest version trough SVN:
[[code]]JCBzdm4gY28gaHR0cDovL3N2bi5zeW1mb255LXByb2plY3QuY29tL2JyYW5jaGVzLzEuMCAu[[/code]]
(and that's it!)
2. Setting up a new project
Symfony consists of a hierarchy of 3 pieces:
- a project
- application(s)
- modules
2.1 Create the project
[[code]]Jmd0OyBta2RpciB+L215cHJvamVjdA0KDQomZ3Q7IGNkIH4vbXlwcm9qZWN0DQoNCiZndDsgcGhwIC9wYXRoL3RvL3N5bWZvbnkvZGF0YS9iaW4vc3ltZm9ueSBpbml0LXByb2plY3QgbXlwcm9qZWN0[[/code]]
Symfony will create a (quiet explicit) directory structure that looks like this:
[[code]]YXBwcy8NCg0KYmF0Y2gvDQoNCmNhY2hlLw0KDQpjb25maWcvDQoNCmRhdGEvDQoNCmRvYy8NCg0KbGliLw0KDQpsb2cvDQoNCnBsdWdpbnMvDQoNCnRlc3QvDQoNCndlYi8=[[/code]]
2.2 Create the application
[[code]]Jmd0OyBzeW1mb255IGluaXQtYXBwIG15YXBw[[/code]]
This will create a [
] directory in the [
] folder of the project root, with a default application configuration and a set of directories ready to host the file of your website:
[[code]]YXBwcy8NCg0KbXlhcHAvDQoNCmNvbmZpZy8NCg0KaTE4bi8NCg0KbGliLw0KDQptb2R1bGVzLw0KDQp0ZW1wbGF0ZXMvDQoNCg==[[/code]]
Some
PHP files corresponding to the front controllers of each default environment are also created in the project [
] directory:
[[code]]d2ViLw0KDQppbmRleC5waHANCg0KbXlhcHBfZGV2LnBocA0KDQo=[[/code]]
[
] is the production front controller of the new application. To run your application in the development environment, call the front controller [
].
Set up your Apache config:
[[code]]Jmx0O1ZpcnR1YWxIb3N0ICo6ODAmZ3Q7DQoNCiAgU2VydmVyTmFtZSBteWFwcC5leGFtcGxlLmNvbQ0KDQogIERvY3VtZW50Um9vdCAiL2hvbWUvc3RldmUvbXlwcm9qZWN0L3dlYiINCg0KICBEaXJlY3RvcnlJbmRleCBpbmRleC5waHANCg0KICBBbGlhcyAvc2YgLyRzZl9zeW1mb255X2RhdGFfZGlyL3dlYi9zZg0KDQogICZsdDtEaXJlY3RvcnkgIi8kc2Zfc3ltZm9ueV9kYXRhX2Rpci93ZWIvc2YiJmd0Ow0KDQogICAgQWxsb3dPdmVycmlkZSBBbGwNCg0KICAgIEFsbG93IGZyb20gQWxsDQoNCiAgJmx0Oy9EaXJlY3RvcnkmZ3Q7DQoNCiAgJmx0O0RpcmVjdG9yeSAiL2hvbWUvc3RldmUvbXlwcm9qZWN0L3dlYiImZ3Q7DQoNCiAgICBBbGxvd092ZXJyaWRlIEFsbA0KDQogICAgQWxsb3cgZnJvbSBBbGwNCg0KICAmbHQ7L0RpcmVjdG9yeSZndDsNCg0KJmx0Oy9WaXJ0dWFsSG9zdCZndDs=[[/code]]
2.3 Create a module skeleton
To add a [
] module to this application, type the following commands:
[[code]]Jmd0OyBjZCB+L215cHJvamVjdA0KDQomZ3Q7IHN5bWZvbnkgaW5pdC1tb2R1bGUgbXlhcHAgbXltb2R1bGU=[[/code]]