Using helpers in actions (Symfony)
We recently had a weird situation here at work where we needed to use the Url helper of Symfony inside the actions.class.php of a module. This helper is available in the view, but not in the actions class by default. The solution is simple, but you need to know it first.
We recently had a weird situation here at work where we needed to use the Url helper of Symfony inside the actions.class.php of a module. This helper is available in the view, but not in the actions class by default.
Of course, we can include this, and this was my first approach. Simply using:
include_once('symfony/helper/UrlHelper.php');
worked fine for me. However, when my co-worker updated his code from Subversion, it went BOOM. He got a rather annoying FATAL error about not being able to redeclare a function. It's weird, because it worked in my situation.
The solution is simple though, and was available in the
Symfony trac. Ticket
#899 contains the solution, which is more simple than you could imagine:
sfLoader::loadHelpers(array('Url'));
Simple!
November 30, 2006 - tags: technology
Ken: How do you find Symfony? Compare to say Zend Framework adn others.
left: Hi Ken,
In an earlier post (http://www.leftontheweb.com/article/291/symfony-no-cacaphony-of-code) I already went into Symfony a bit. I love it, basically. It takes all the annoying work out of the hands of the developer. Compared to for instance Zend Framework, Symfony is just more mature. I definitely see an interesting future for ZF, but not at this moment. The API is not set in stone yet, too much is being refactored without regard for backwards compatibility. Symfony is nearing 1.0 stable and is actually aiming to release that this year.
So yes, I am very happy with Symfony.

denderello: Thanks skoop! You saved my day!
left: Hi denderello,
Old though this post may be, good that it is still of use
Stefan

pepe18: sfLoader no longer exists, use this:
sfApplicationConfiguration::getActive()->loadHelpers(array('Url'));
what causes pneumonia: Stefan, can you please drop me an email regarding Metal Machine Music Live/ Thanks.
Time Warner Packages: Nice posting... I like it! Thanks for sharing. Keep on posting…
tilting patio umbrella: I'm still learning from you, however I'm improving myself. I definitely love studying every little thing that is written on your blog.Preserve the stories coming. I cherished it!
LED spotlight: You also know how to make people rally behind it, obviously from the responses.
debt consolidation: Symfony is aimed at building robust applications in an enterprise context, and aims to give developers full control over the configuration: from the directory structure to the foreign libraries, almost everything can be customized. To match enterprise development guidelines, Symfony is bundled with additional tools to help developers test, debug and document projects. Thanks.