The blog of COil: PHP, PEAR, symfony1, Symfony2 & iWeb2.0+

Strangebuzz...?

» Collapse all «

Tag - symfony

     

Thursday 9 February 2012

Simple bash script to update Symfony2

As you noticed there are frequent maintenance releases of Symfony2, the 2.0.10 version is already out. To avoid doings thing manually I use this simple bash script to make the update: (It works with a Symfony2 standard edition). To use it, just launch the script at the root of your project: (be careful as it will delete your vendor directory)

./update_symfony 2.0.10

The bash script:


See you. :)

Other related posts;

Wednesday 8 February 2012

Une semaine symfonique #266 - du 30 janvier au 5 février 2012

Post original: A week of symfony #266 (30 January -> 5 February 2012) )


Cette semaine une montagne de bugs ont été corrigés sur la branche "master" Symfony2 ainsi que de nombres améliorations et re-factorisaions concernant les composants "Formulaire" et "Validation". De plus, le dépôt officiel Symfony2 a atteins la limite symbolique des 1000 "forks".

Continue reading...

Tuesday 31 January 2012

Une semaine symfonique #265 - du 23 au 29 janvier 2012

Post original: A week of symfony #265 (23->29 January 2012)


Cette semaine les collecteurs time, logger et Doctrine ont été améliorés et refactorisés. Pendant ce temps, de nombreux bug ont été corrigés sur le composant Form, particulièrement concernant l'amélioration de l'interface ChoiceListInterface et de ses implémentations.

Continue reading...

Saturday 28 January 2012

Load fixtures with Symfony2 and YAML files

Hi Symfonians ! :)

I am actually spending a lot of time on testing Symfony2. When building an application, one of the first thing you will have to do is to insert initial datas, also called fixtures, so you can use and test your application. There is a documentation on the Symfony website about this subject, it uses the DoctrineFixturesBundle.

It works very well, but I wanted to use YAML files "a la symfony1". So I ended up with this simple solution:

The base Loader class:

First, I create a base Loader class that others entities loaders will extend:


The getModelFixtures() function will load the YAML file corresponding to the current entity, the getModelFile() function will have to be implemented by sub-loaders. The class implements the ContainerAwareInterface so we can access the DIC in the loaders.

The Category loader:


The YAML file:

Both jobs and categories YAML files are almost equal to the Jobeet1 tutorial ones.


The loader class:

The getModelFixtures() function retrieves the fixtures for the Category entity and then you just have to iterate over the array. At each iteration we add a reference to the entity so it can be used in other loaders. (as a foreign key)

The Job loader:


The YAML file:


The loader class:


Same here, but:

  • For each iteration we retrieve the proper category reference we already built in the Category loader (line 30).
  • In Jobeet1 there was a loop directly in the YAML file in order to add lot of job rows, now we can do this loop in our loader: duplicateLastJob().
  • There is also a special case where we force a value for the expiresAt date field that would be overridden by the Job object life-cycle callbacks otherwise.

I think this a good approach as you have the ease of writing YAML without loosing the possibility to handle complex or edge cases with PHP. You can find the code on github.

See you ! COil :)

PS: This tutorial was tested with Symfony Standard Edition 2.0.9.
PS2: If you have a blog post about fixtures, let me know so I can add it below.

Other posts about fixtures:

Monday 23 January 2012

Une semaine symfonique #264 - du 16 au 22 janvier 2012

Post original: A week of symfony #264 (16->22 January 2012)


Cette semaine, les composants Form et Validator ont connu l'activité la plus importante de la branche master. Tout d'abord, la CollectionValidator a introduit les nouvelles contraintes "Optional" et "Required". Ensuite, la validation des formulaires imbriqués a été rendue configurable, c'est à dire que ces derniers ne sont désormais plus validés par défaut. (changement non rétrocompatible)

Continue reading...

Monday 16 January 2012

Une semaine symfonique #263 - du 9 au 15 janvier 2012

Post original: A week of symfony #263 (9->15 January 2012)


Cette semaine la branche master de Symfony2 s'est vue commité un important changement concernant la sécurité, celui-ci n'étant pas rétrocompatible: moved user comparison logic out of UserInterface. De plus, les gagnants des "Symfony Community Awards" ont été annoncés !

Continue reading...

Monday 9 January 2012

Une semaine symfonique #262 - du 2 au 8 janvier 2012

Post original: A week of symfony #262 (2->8 January 2012)


Cette semaine la future version 2.1 de Symfony a supprimé le DoctrineBundle puisqu'il a été migré dans l'organisation Doctrine. Pendant ce temps, la toute nouvelle documentation des composants Symfony2 a mise en ligne. Finalement, la version de maintenance 2.0.9 de Symfony a été publiée, elle corrige quelques problèmes mineurs introduits par la précédente version.

Continue reading...

Friday 6 January 2012

Extending the Symfony2 session

Hi symfonians ! :)

If you are used to symfony1, you probably noticed that you don't have a myUser class to handle the user session. It's generally useful so you don't have to handle directly with session attributes and you can also have shortcuts. Well it's quiet easy to have such a class in Symfony2:
Declare your own session class as the framework level in your app/config.yml config file:


And now create your own mySession class which extends the default Symfony2 session class:


And your done. :)

PS: The class can be stored in another location, I'm not sure which is the best ?
PS2: The service could also be loaded at the Bundle level.

Tuesday 3 January 2012

Une semaine symfonique #261 - du 26 décembre 2011 au 1 janvier 2012

Post original: A week of symfony #261 (26 December 2011 -> 1 January 2012)


La dernière semaine de l'année a vu voir le jour de la version 2.0.8 de Symfony ainsi que l'ajout de la fonctionnalité "réponses en flux continu" (Si vous avez une meilleure traduction !?) à la future version 2.1 de Symfony.

Continue reading...

Monday 26 December 2011

Une semaine symfonique #260 - du 19 au 25 décembre 2011

Post original: A week of symfony #260 (19->25 December 2011)


Cette semaine, la branche master de Symfony2 s'est concentré sur une importante refactorisation du DoctrineBridge. De plus, un nouveau composant a été créé pour la classe Filesystem. Enfin, la branche 2.0 a été rendue compatible avec la future version 1.5 de Twig.

Continue reading...

- page 1 of 5