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

Richard Melo:
Run legacy PHP applications from command line
Feb 15, 2016 @ 17:55:49

Richard Melo has a post to his site sharing some helpful advice about running legacy PHP applications from the command line making use of the Symfony Console component to handle some of the heavy CLI duties.

Imagine that you already have a trustfully application that you have been running for a while, but there is a couple of common patterns that make you consider that you need a command line interface (CLI) for your application. [...] So, how do we do this? especially without reinventing the well?

He starts off with an example of the problem, having a bit of a legacy application that needs to take in data (in this case JSON) and handle it would requiring a form submission. He makes use of the Console component to wrap this functionality inside a command and take a JSON file as input. He includes the example code needed to make this simple setup including the Command class itself and a small "bootstrap" command line script to do the actual command execution. The post ends with an example of the command you'd use to run the script and push in the JSON contents.

tagged: commandline symfony console component legacy wrapper introduction tutorial

Link: http://rjsmelo.com/blog/2016/01/19/run-legacy-php-applications-from-command-line/


Trending Topics: