Embed URL


SSH clone URL

You can clone with HTTPS or SSH.

Download Gist




A tool for interacting with PHP code from the command line. It is intended to be used alongside Respect\Config.

Main Actions

Usage: [action] [config] [command]

  • print -p shows up a shell-friendly representation of the given command
  • serve -s opens up a standalone PHP server serving the given command
  • start -d opens up a PHP daemon for the given command
  • interactive -a lets the user interact with the code

Usage Samples

Prints out tables from a MySQL database using PDO:

$ respect print Pdo --dsn='mysql:localhost;dbname=mydb' --user=root --password='' query 'SHOW TABLES'

Arguments starting with '--' are configuration/instantiation, other arguments are commands. Commands are always 'fluent', so the next command always runs upon the last command return.

This is equivalent to:

$command = new PDO('mysql:localhost;dbname=mydb', 'root', '');
$command = $command->query('SHOW TABLES');
return Respect\Cli\TextFormatter($command);

Using an external Respect\Config INI file:

$ respect print --myconfig.ini db query 'SHOW TABLES'

INI file:

[db Pdo]
dsn = mysql:localhost;dbname=mydb
user = root
password = ""

Interactive usage

Type the initial INI file:

$ respect interactive --myconfig.ini

Tab to auto-complete to container keys:

$ db 

Tab again to auto-complete to methods/properties/constructor-parameters of that instance:

$ db query 

Type your commands:

$ db query 'SHOW TABLES'

Great idea, let's code?


@henriquemoody yes!

The interative part i have no fucking idea of how to code, BUT, great idea. =D


We leave the interactiveness for the future. Probably a lot of Reflection to auto-complete these guys and a lot of dynamic Respect\Config containers being altered in runtime.

I don't know if this would help you, but I'm developing Clinner a CLI commands abstraction for PHP5.3+ which allows to run and chain both CLI commands and PHP functions. If you feel like it, you can check it out here.


@ncuesta I do like your approach on Clinner! I have some suggestions on the API/Interface for it, let me know if you are willing to know them =D Not sure how I would use it in Respect\Cli yet, but for sure it will be very handy on other projects.

Hey @alganet, Clinner's issues are open :) I'm always available for other points of view. Thanks! And if you would like any kind of help on this, I'd be more than happy to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.