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

SitePoint PHP Blog:
Symfony2 Console: Getting Started with Console Helpers
Apr 09, 2015 @ 15:44:03

If you've ever worked with the Symfony Console component and wanted to enhance the experience with some additional functionality, check out the latest tutorial from the SitePoint PHP blog: Symfony2 Console: Getting Started with Console Helpers.

In this tutorial, I’ll share my experiences and we’ll give some extra love to the console helpers, which provide us with a large collection of handy functions. There are a lot of reasons to create console commands in your projects: sending emails, exporting/importing data, creating users, and so on. [...] By the end of this post, we want to be able to create a basic console command to generate some output – any output will do – only the way to getting there is important. Near the end, we’ll discover some console helpers in order to create some nice interactions between users and the interface.

He starts by helping you get the component installed via Composer and creating the first simple command line script (a ConsoleApplication). He shows how to add in a basic "hello world" command (conveniently named "BasicCommand") and the result when executed. With this in place, he starts in on three helpers:

  • Question Helper
  • Table class
  • Progress Bar

Each includes the code needed to implement it and the resulting output. You can find out more about the component in the Symfony2 documentation.

tagged: symfony2 console tutorial command helpers introduction question table progressbar

Link: http://www.sitepoint.com/symfony2-console-getting-started-console-helpers/


Trending Topics: