The blog of COil : PHP, symfony & Web 2.0

Strangebuzz...?

Réduire au titre / collapse all

18/03/2008

» Symfony tip : Registration of plugin routes

[En] Here is a little tip Fabien gave me. I am actually developing a plugin witch has quiet a lot of routes (about 40). Normally you can add the routes with the prependRoute function, like does the sfGuardplugin.

<?php
if (sfConfig::get('app_sf_guard_plugin_routes_register', true) && in_array('sfGuardAuth', sfConfig::get('sf_enabled_modules', array())))
{
  $r = sfRouting::getInstance();
 	
  // preprend our routes
  $r->prependRoute('sf_guard_signin', '/login', array('module' => 'sfGuardAuth', 'action' => 'signin'));
  $r->prependRoute('sf_guard_signout', '/logout', array('module' => 'sfGuardAuth', 'action' => 'signout'));
  $r->prependRoute('sf_guard_password', '/request_password', array('module' => 'sfGuardAuth', 'action' => 'password'));
}
?>


But for each prependRoute call an array_merge is done on all existing routes.

<?php
  /**
   * Adds a new route at the beginning of the current list of routes.
   *
   * @see connect
   */
  public function prependRoute($name, $route, $default = array(), $requirements = array())
  {
    $routes = $this->routes;
    $this->routes = array();
    $newroutes = $this->connect($name, $route, $default, $requirements);
    $this->routes = array_merge($newroutes, $routes);
 
    return $this->routes;
  }
?>


So the tip here is to save all routes, clear them, add the routes of the plugin and then append the saved routes. Witch can be done like this:

<?php
  // Save and clear all routes
  $r = sfRouting::getInstance();
  $routes = $r->getRoutes();
  $r->clearRoutes();
  
  // Plugin home
  $r->connect('plugin_home', '/my_super_plugin/homepage', array(
    'module' => 'my_plugin_module', 
    'action' => 'my_plugin_action',
    'additional_parameter'   => 1
    ));
 
  // Another route
  $r->connect('plugin_home', '/my_super_plugin/section1', array(
    'module' => 'my_plugin_module', 
    'action' => 'my_plugin_action_section1',
    'additional_parameter'   => 2
    ));
 
  // ... other routes
 
  // Then merge new routes with the saved one
  $r->setRoutes($r->getRoutes() + $routes);
?>


That's it. :) Of course it is always better to have all routes of the application in the routing.yml but in my case it was not possible.

27/10/2007

» GamesOfficer powered by symfony

[En] I didn't had much time to blog these last weeks... :/ Indeed we were finishing a new project, an e-commerce website called GamesOfficer. And obviously, it is powered by the last stable version of symfony. (currently 1.0.8). What is GamesOfficer ? Well, it's quite like PriceMinister but exclusively about gaming universe. You can buy games (all platforms), accessories... (in france) I am involved in the development of this site since 5 month for the Splitgames company, and we are quiet proud of it ! About the use of symfony in this website:

  • 26 plugins used (including 8 home made) (and 2 of mines Lightbox and TCPDF :) )
  • 13 new helpers classes were developed (like JSON, generic ajax pager...)
  • 19 specific new pake tasks
  • Some snippets of symfony were used and improved (like the TCPDF wiew, Array pager... )
  • Ajax helpers are used among the site, like in the advanced search

... quite hard to say all, i think developing this website without symfony would have take 3 more times !!! :) And moreover the site is really beautifull. Don't you like the GamesOfficer mascot ? :)


GamesOfficer homepage



About symfony, the actual activity arround this framework is quite incredible. If you follow the "a week of symfony" blog post by Javier Eguiluz, it's not so hard to realize... I must say it's now hard to follow all new plugins ! I'll have to take some time to check and test the new ones ! But thanks for all contributors and perhaps symfony could make the coffee soon with the sfCoffeePlugin ? ;)

10/03/2007

» Brêves de comptoir n°1

[EN] Click here for the english version / see below

[FR] Pas le courage de poster régulièrement donc voici quelques news en vrac :

  • myBlog

J'ai fait quelques ajouts à mon blog pour le fun, notemment les tags des billets, les tags del.icio.us ainsi que mes dernières url, une pub Google (juste pour tester la chose), quelques petites retouches de css, j'ai aussi fait une page dédiée à mes bookmarks del.icio.us avec un gros nuage de tags et mes 50 dernères url postées, trés pratique pour retrouver rapidement ses infos.

Une nouvelle qui est restée assez discréte je trouve, l'entreprise des concepteurs de Symfony, Sensio a fusionnée avec Extreme pour donner 2 nouvelles entités, Extreme Sensio qui propose une offre "360°" pour le web et Sensiolabs dédié à l'open source et notemment au framework Symfony bien sûr. Une trés bonne nouvelle une fois de plus pour la perennité de ce framework. Je leur souhaite evidemment une trés bonne réussite.

Oui je sais ca fait déjà un moment, on l'attendait depuis longtemps et je ne suis pas décu c'est un trés bon cru, en même temps les gros "changements" sont déjà la depuis pas mal de temps. On peut citer par exemple le nouveau sytème de plugin qui est vraiment intéressant pour capitaliser son code, j'ai aussi testé le système intégré de livraison de code, c'est vraiment hyper pratique, on définit les références de son serveur distant, les fichiers à exlcure de la mise à jour, on fait une 1ere simuation, on valide et c'est fini. (voir la commande >symfony sync)

J'ai avancé sur mon plugin, il gère désormais les formulaires et permet d'utiliser les helpers Ajax symfony direcetement à l'intérieur de l'application Joomla. Je devrais livrer cette version 0.8.0 beta courant de semaine prochaine.

  • Antiséche Symfony : les commandes console

J'ai repéré une anti-séche bien sympa sur les commandes Symfony. Vous pouvez la trouver sur le blog d'Andreia, il y a aussi un graphique récapitulatif sur l'intégration de l'ORM Propel dans Symfony.

Lire la suite / read all

28/01/2007

» Productivity Killers Awards

[En] I found a very interesting article about productivity in the n°363 nexen php newsltetter (by Laurent Ploix), it notes the top twelve reasons that can make a developer loose productivity, the 3 main points for me were :

  • Fact 5: Bugs increase as the number of developers increases.
  • Fact 10: Defining the architecture is as important as coding
  • Fact 12: Coding conventions are efficient; they must be imposed.



[Fr] J'ai relevé un article trés intéressant dans la newsletter Nexen n°363 (par Laurent Ploix), il mentionne les 12 points principaux qui font baisser de manière significative la productivité dans le développement. J'ai plus particulièrement noté les 3 points suivants :

  • Fait 5: Les bugs augmentent avec le nombre de développeurs.
  • Fait 10: Mettre en place une bonne architecture est aussi imporatant que le dévelopement lui même.
  • Fait 12: Les conventions de programmation sont efficaces, elles doivent être imposées.


13/01/2007

» myBlog.class.php

[En] Welcome on my new blog that will mainly talk about PHP, the Symfony framework and web2.0.

[Es] Bienvenido en mi nuevo blog, principalmente hablando sobre PHP, Symfony framework y web2.0.

[Fr] Voilà je me suis décidé à ouvrir mon Blog, non pour raconter ma vie... quoi que ;) ... Mais pour parler essentiellement de programmation, notemment PHP et le framework Symfony dont je suis trés friand ces derniers temps. ;) J'ai choisi DotClear pour sa réputation, sa facilité d'utilisation, les thèmes disponibles et les plugins. Je ne suis vraiment pas déçu pour l'instant. C'est propre et clair. J'ai du installer un plugin intégrant Geshi pour la coloration synthaxique PHP.


Présentation

Une petite présentation (vite-fait hein...) je suis COil (devinez-mon prénom ?), j'ai 28 ans... Et je me suis re-mis (**sérieusement**) au PHP et aux technos web depuis 6 mois apres une longue mission à Paris, ça fait du bien. La conception technique de sites web, le php et le webmastering étant vraiment les disciplines que je préfére.


J'espère que vous pourrez trouver ici quelques informations intéressantes à l'occasion. (pas toujours quand même, faut pas pousser...) :o

» Autres billets / Other post