I've created a few personal command line apps to help my productivity and reduce time completed repetative jobs. One of my go-to frameworks to use is CLImate, a command line app framework created by thephpleague. The framework provides a clear syntax which speeds up the development of command line apps.

Getting started

  • Make file executable
  • Composer file
  • pubishing package

To start, create a new php file and add this to the top...

#! /usr/bin/env php

This first line lets the terminal/command line that this file is to be treated like a script. After doing this, we make the file executable.

$ sudo chmod +x your_script_file.php;

This will allow us to run the script when we run the following command.

$ ./your_script_file.php;

Moving on, adding CLImate to this project requires creating a new CLImate object:

$climate = new league/climate/climate;

This allows us to access the powerful features of the framework. We'll begin by just output a simple message.

$climate = new League/CLImate/CLImate;

...

$climate->out('This is a new message');

Now running the previous terminal command will output the following

$ ./your_script_file.php;
This is a new message