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

Agustín Houlgrave:
A guide to a proper PHP Console Application
Feb 08, 2018 @ 17:14:28

On his Medium.com site Agustín Houlgrave has posted a tutorial with some suggestions about building PHP console applications correctly.

Googling this topic, I could only find official documentation on Symfony’s Console Component and some tutorials on quick building, but i’d like to write about making a real scalable console application that you could use in an actual production project. I’ll explain the reasons we do each of the things.

I like to write decoupled, reusable and as raw as possible code, so we’ll try to aim on that direction. Also, we’ll take advantage of all of the new features of PHP 7.

He decided on the combination of the Symfony Console Component and the Zend Service Manager to handle the use of the decoupled components. He then gets into the installation of the required packages and the initial code to create the Symfony command. He then sets up the Composer autoloading and the "factory" configuration for the command. From there he includes the code to build out the command runner and gives an example of executing the command and the output.

tagged: console command symfony tutorial zendframework servicemanager component

Link: https://medium.com/@a.houlgrave/a-guide-to-a-proper-php-console-application-325ef677faf1


Trending Topics: