Nandeesh Mp Developer & Open Source Enthusiast

Command Line Todo with Symfony - Part 1

In this series of articles, We’ll be building a simple To-do console app using Symfony console component. To start with lets pull the following packages from composer repository -

Note we are using psr-4 autoloading and namespaced our app as TaDa Our ToDo app need the following functionalites -

Since we want to show list items after every addition and deletion, lets include it in our base class and every other class inherit it.

namespace TaDa;
use Simplon\Mysql\Mysql;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class Command extends SymfonyCommand
    private $dbConn;

    public function __construct(Mysql $dbConn)
        $this->dbConn = $dbConn;


    public function showList(OutputInterface $output)
        $tasks = $this->dbConn->fetchRowMany('SELECT id, task FROM tasks');

        $table = new Table($output);