TRAJOIN is an Application to Translate symfony documents Jointly.

home > 1.2/jobeet/en > 24.txt

[1] Edit ↑TOP

Day 24: Another Look at symfony


[2] Edit ↑TOP

Today is the last stop of our trip to the wonderful world of symfony. During these twenty-three days, you learned symfony by example: from the design patterns used by the framework, to the powerful built-in features. You are not a symfony master yet, but you have all the needed knowledge to start building your symfony applications with confidence.


[3] Edit ↑TOP

As we wrap up the Jobeet tutorial, let's have another look at the framework. Forget Jobeet for an hour, and recall all the features you learned during the last three weeks.


[4] Edit ↑TOP

What is symfony?


[5] Edit ↑TOP

The symfony ~framework|Framework~ is a set of cohesive but decoupled sub-frameworks, that forms a full-stack MVC framework (Model, View, Controller).


[6] Edit ↑TOP

Before coding head first, take some time to read the symfony history and philosophy. Then, check the framework prerequisites and use the check_configuration.php script to validate your configuration.


[7] Edit ↑TOP

Eventually, install symfony. After some time you will also want to upgrade to the latest version of the framework.


[8] Edit ↑TOP

The framework also provides tools to ease deployment.


[9] Edit ↑TOP

The ~Model~


[10] Edit ↑TOP

The Model part of symfony can be done with the help of the


[11] Edit ↑TOP
[For propel]

Propel ORM. Based on the


[13] Edit ↑TOP
[For doctrine]

Doctrine ORM. Based on the


[14] Edit ↑TOP

database description, it generates classes for objects, forms, and filters. Propel or Doctrine also generates the SQL statements used to create the tables in the database.


[15] Edit ↑TOP

The database configuration can be done with a task or by editing a configuration file. Beside its configuration, it is also possible to inject initial data, thanks to fixture files. You can even make these files dynamic.


[17] Edit ↑TOP
[For propel]

Propel objects can also be easily internationalized.


[19] Edit ↑TOP
[For doctrine]

Doctrine objects can also be easily internationalized.


[21] Edit ↑TOP

The ~View~


[22] Edit ↑TOP

By default, the View layer of the MVC architecture uses plain PHP files as templates.


[23] Edit ↑TOP

Templates can use helpers for recurrent tasks like creating a URL or a link.


[24] Edit ↑TOP

A template can be decorated by a layout to abstract the header and footer of pages. To make views even more reusable, you can define slots, partials, and components.


[25] Edit ↑TOP

To speed up things, you can use the cache sub-framework to cache a whole page, just the action, or even just partials or components. You can also remove the cache manually.


[26] Edit ↑TOP

The ~Controller~


[27] Edit ↑TOP

The Controller part is managed by front controllers and actions.


[28] Edit ↑TOP

Tasks can be used to create simple modules, CRUD modules, or even to generate fullly working admin modules for model classes.


[29] Edit ↑TOP

Admin modules allows you to built a fully functional application without coding anything.


[30] Edit ↑TOP

To abstract the technical implementation of a website, symfony uses a routing sub-framework that generates pretty URLs. To make implementing web services even easier, symfony supports formats out of the box. You can also create your own formats.


[31] Edit ↑TOP

An action can be forwarded to another one, or redirected.


[32] Edit ↑TOP

~Configuration~


[33] Edit ↑TOP

The symfony framework makes it easy to have different configuration ~settings|Settings~ for different ~environments|Environments~. An environment is a set of settings that allows different behaviors on the development or production servers. You can also create new environments.


[34] Edit ↑TOP

The symfony configuration files can be defined at different levels and most of them are environment aware:


[35] Edit ↑TOP
[36] Edit ↑TOP

The configuration files mostly use the YAML format.


[37] Edit ↑TOP

Instead of using the default directory structure and organize your application files by layers, you can also organize them by feature, and bundle them in a plugin. Speaking of the default directory structure, you can also customize it according to your needs.


[38] Edit ↑TOP

~Debugging|Debug~


[40] Edit ↑TOP
[For propel]

From logging to the web debug toolbar, and


[42] Edit ↑TOP
[For doctrine]

From logging to the web debug toolbar, and


[43] Edit ↑TOP

meaningful exceptions, symfony provides a lot of useful tools to help the developer debug problems faster.


[44] Edit ↑TOP

Main symfony Objects


[45] Edit ↑TOP

The symfony framework provides quite a few core objects that abstract recurrent needs in web projects: the request, the response, the user, the logging, the routing, and the view cache manager.


[46] Edit ↑TOP

These core objects are managed by the sfContext object, and they are configured via the factories.


[47] Edit ↑TOP

The user manages user authentication, authorization, flashes, and attributes to be serialized in the session.


[48] Edit ↑TOP

~Security~


[49] Edit ↑TOP

The symfony framework has built-in protections against XSS and CSRF. These settings can be configured from the command line, or by editing a configuration file.


[50] Edit ↑TOP

The form framework also provides built-in security features.


[51] Edit ↑TOP

~Forms~


[52] Edit ↑TOP

As managing forms is one of the most tedious task for a web developer, symfony provides a form sub-framework. The form framework comes bundled with a lot of widgets and validators. One of the strength of the form sub-framework is that templates are very easily customizables.


[53] Edit ↑TOP

If you use Propel or Doctrine, the form framework also makes it easy to


[54] Edit ↑TOP
[For propel]

generate forms and filters based on your models.


[56] Edit ↑TOP
[For doctrine]

generate forms and filters based on your models.


[58] Edit ↑TOP

Internationalization and Localization


[59] Edit ↑TOP

Internationalization and localization are supported by symfony, thanks to the ICU standard. The user culture determines the language and the country of the user. It can be defined by the user itself, or embedded in the URL.


[60] Edit ↑TOP

Tests


[61] Edit ↑TOP

The lime library, used for unit tests, provides a lot of testing methods. The


[62] Edit ↑TOP
[64] Edit ↑TOP
[65] Edit ↑TOP

a dedicated database and with dedicated fixtures.


[66] Edit ↑TOP

Unit tests can be run one at a time or all together.


[67] Edit ↑TOP

Functional tests are written with the sfFunctionalTest class, which uses a browser simulator and allows symfony core objects introspection through Testers. Testers exist for the request object, the response object, the user object, the current form object, the cache layer and the


[68] Edit ↑TOP
[For propel]

[70] Edit ↑TOP
[For doctrine]

[72] Edit ↑TOP

You can also use debugging tools for the response and forms.


[73] Edit ↑TOP

As for the unit tests, functional tests can be run one by one or all together.


[74] Edit ↑TOP

You can also run all tests together.


[75] Edit ↑TOP

Plugins


[76] Edit ↑TOP

The symfony framework only provides the foundation for your web applications and relies on plugins to add more features. In this tutorial, we have talked about sfGuardPlugin, sfFormExtraPlugin, and sfTaskExtraPlugin.


[77] Edit ↑TOP

A plugin must be activated after installation.


[78] Edit ↑TOP

Plugins are the best way to contribute back to the symfony project.


[79] Edit ↑TOP

~Tasks~


[80] Edit ↑TOP

The symfony CLI provides a lot of tasks, and the most useful have been discussed in this tutorial:


[81] Edit ↑TOP
[82] Edit ↑TOP
[For propel]

[84] Edit ↑TOP
[For doctrine]

[85] Edit ↑TOP
[86] Edit ↑TOP

You can also create your own tasks.


[87] Edit ↑TOP

See you soon


[88] Edit ↑TOP

Before you leave, I would like to talk about one last thing about symfony. The framework has a lot of great features and a lot of free documentation. But, one of the most valuable asset an Open-Source can have is its community. And symfony has one of the most amazing and active community around. If you start using symfony for your projects, consider joining the symfony community:


[89] Edit ↑TOP

[90] Edit ↑TOP

ORM


Comments

Menu

Documentation



Latest Histories

Untranslated