Download the PHP package eduavila/slim-commander without Composer
On this page you can find all versions of the php package eduavila/slim-commander. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eduavila/slim-commander
More information about eduavila/slim-commander
Files in eduavila/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 for Slim v4
A very simple structure for running CLI commands as part of your Slim Framework application v4.
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