CLI for Slimframework

Before going to implement CLI for slimframework then we should know about slimframework

What is slim framework ?

Slim framework is lightweight micro framework and it helps to quickly implement web application as well as API’s.

Official website:

Today we are going to implement CLI(Command Line Interface) for slimframework by using top of the symfony components and it helps to application background process.

First we need to install slimframework using composer. So create composer.json at your project root folder.

For example i have a project name is “slim” . 

see my composer.json:

I have used symfony console to build the CLI for slimframework. Then install composer via command line


Now all packages are installed under vendor folder. Now folder structure

And then create cli.php in your project root

Then add console initialization code  to cli.php file

Now CLI is ready for slim framework. Just go to the project root directory and type “php cli.php” in command line then you can see the magic.



That’s it. Thank you..

  • Pingback: Timothy()

  • HPK


  • john

    how to run by route?

    • Azhagu pandian

      We will see it in next tutorial.