News Feed
Sections




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

SitePoint PHP Blog:
Command line PHP using Symfony Console
December 12, 2013 @ 10:34:15

The SitePoint blog has a new post from Daniel Gafitescu covering the use of the Symfony Console component to create command line PHP scripts quickly and easily.

As a PHP developer, you will often find yourself working with PHP in the command line. The first time I had to use it was because I would get the "Maximum execution time of 30 seconds exceeded" error on a shared server where you could not change the max_execution_time PHP setting. Nowadays building command line scripts is much easier than it used to be. If you search on Packagist you will find a lot of packages to work with the command line but the one that stands out and is the most commonly used is Symfony/Console.

He starts with what you'll need to add to your Composer configuration to pull in a development version (2.4.x-dev) of the component. With that installed, he sets up a base directory ("/app") and a basic skeleton for your application. For his first command, he creates a script that will calculate the fibonacci numbers between two given numbers. He shows how to work with the input and Output objects inside the script and the code for the finished command - including some screenshots of the output.

0 comments voice your opinion now!
command line cli symfony console tutorial

Link: http://www.sitepoint.com/command-line-php-using-symfony-console/

blog comments powered by Disqus

Similar Posts

Ben Ramsey: Setting Up Jenkins on Amazon Linux for PHP Testing

Inviqa techPortal: Speedy Sites: Nginx and PHP

Padraic Brady's Blog: The Mysteries Of Asynchronous Processing With PHP - Part 2 (CLI applications)

Jeremy Cook's Blog: Implementing IteratorAggregate and Iterator

Geshan Manandhar: 3 Bundles to get started with REST in Symfony 2 and some tips


Community Events

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


laravel opinion framework api library voicesoftheelephpant install series extension xdebug introduction community example interview php7 unittest language podcast laravel5 release

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