Download the PHP package wilkques/console without Composer
On this page you can find all versions of the php package wilkques/console. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package console
Console for PHP
English | 繁體中文
`
Upgrading from 3.x? Declared flags like
{--force}changed default fromtruetofalse, undeclared options are now rejected, andhandle()now returns an exit code your entry script must pass toexit(). Read UPGRADING.md first.
How to use
-
Add a PHP command file.
Command classes are discovered by path, and their fully-qualified class name is derived from your root
composer.json'spsr-4map — so the command directory must sit under a psr-4 root, and the class must declare the matching namespace. With{"autoload": {"psr-4": {"App\\": "app/"}}}, put this atapp/Console/DoSomethingCommand.php: -
in terminal run
vi artisan& Add PHP code - in terminal run
php artisan do:something --debug
Argument syntax
Positional arguments are declared with {name} in the signature, and are
read back inside handle() via $this->argument('name'):
{name}— required. Running the command without it aborts withNot enough arguments (missing: "name").and a non-zero exit code.{name?}— optional. Resolves tonullif not given on the CLI.{name=default}— optional, with a default value used when not given.{name*}— optional, collects every remaining positional value into an array (must be the last argument in the signature).
Passing more positional values than the signature declares (and the last
argument isn't a * array argument) also aborts, with
Too many arguments, expected arguments "...".
Option syntax
Options are declared with {--name} inside the signature and read back with
$this->option('name'):
{--force}— a boolean flag. Defaults tofalse; passing--forceon the command line makes ittrue.{--force=true}— a boolean flag that defaults totrue.{--name=guest}— takes a value, defaulting toguest.{--name=}— takes a value, defaulting tonull.
Add a description after the first : — {--force : skip confirmation}. Only
the first : separates the token from its description, so defaults may
themselves contain colons: {--dsn=mysql:host=localhost : the DSN} keeps its
full value.
An option that the signature does not declare is an error:
Exit codes
| situation | exit code |
|---|---|
handle() returns null / nothing |
0 |
handle() returns an int |
that int |
| help screen (no command given) | 0 |
| unknown command, bad arguments, undeclared option | 1 |
| uncaught exception inside a command | non-zero |
Errors are written to stderr, so they can be redirected separately from a command's normal output.
All versions of console with dependencies
wilkques/container Version >=5.0.0
wilkques/php-helper Version ^6.1.0
wilkques/filesystem Version >=1.0.1