News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matthias Noback:
Symfony2 Add a global option to console commands and generate a PID file
November 26, 2013 @ 14:06:11

Cal Evans has pointed out a post by Matthias Noback related to Cal's "Signaling PHP" book and an idea presented in one of the appendices - working with PID files as a global option. Mattias writes:

Recently I read the book Signaling PHP by Cal Evans. It's a short book, yet very affordable and it learned me a couple of things. First of all it explains about how you can "capture" a Ctrl+C on your long-running command and do some necessary cleanup work before actually terminating the application. In the appendix it also mentioned the interesting concept of a PID file. [...] In Appendix A of "Signaling PHP", Cal writes about a way to extend a Symfony command to automatically create such a PID file before executing its task, and to delete this file afterwards.

Mattias shares what he calls a "hack" to make it happen globally - using the eventing system built into the Symfony Console functionality and the "console.command" event. He creates a bundle to help with the reading/writing of the PID file and shows how to implement it as a part of the event handling. He does point out one problem with this method (that the "input" object isn't available) so he works around it with the "ArgvInput" component and some manual handling to grab the PID file location provided.

0 comments voice your opinion now!
symfony2 console option command pid file tutorial bundle

Link: http://php-and-symfony.matthiasnoback.nl/2013/11/symfony2-add-a-global-option-to-console-commands-and-generate-pid-file/

blog comments powered by Disqus

Similar Posts

Master Zend Framework: Running the ZF2Skeleton with PHP’s Built-in Webserver

DevShed: Working with Multiple Template Files to Separate Logic from Presentation (Part 3)

Gary Sieling: Scraping Google Maps Search Results with Javascript and PHP

Gonzalo Ayuso: Handling several DBALs in Symfony2 through the Dependency Injection with PHP

PHPBuilder.com: Implementing the Singleton Pattern in PHP 5


Community Events





Don't see your event here?
Let us know!


developer laravel introduction interview language code application api project configure series wordpress podcast bugfix release library framework threedevsandamaybe community list

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework