Download the PHP package drewm/slim-commander without Composer
On this page you can find all versions of the php package drewm/slim-commander. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download drewm/slim-commander
More information about drewm/slim-commander
Files in drewm/slim-commander
Package slim-commander
Short Description A very simple structure for running CLI commands as part of your Slim Framework application
License MIT
Homepage http://github.com/drewm/slim-commander
Informations about the package slim-commander
SlimCommander
A very simple structure for running CLI commands as part of your Slim Framework application.
This is not a console tool. It's just a parallel to the HTTP entry point into your application, enabling you to do things like create create scripts to be run as cronjobs or set up basic queue listeners.
Usage
Taking the structure of Slim-Skeleton as an example, your public/index.php
does this:
You need to create a new PHP script, similar to this, to serve as the entry point for your commands.
It should be outside the public
folder. Perhaps src/cli.php
.
Instead of routes, you define commands in e.g. src/commands.php
.
Arguments are:
- Name of the command
- The callback, defined in the same way as a regular Slim route callback
- An array of expected argument names
In the above example, the first argument will be passed to the callback as name
Your callback gets the container passed to its constructor:
Add it to your container, just as you would normally:
And then you'd execute it with php src/cli.php HelloWorld Fred