Download the PHP package lotfio/conso without Composer
On this page you can find all versions of the php package lotfio/conso. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package conso
Conso (PHP console applications for cool kids).
🔥 Introduction :
Conso is a simple, lightweight PHP package that helps you create (executable, .phar, shareable) command line applications easily.

:collision: Is it really lightweight ?
📌 Requirements :
- PHP >= 7.2 or newer versions
- PHPUnit >= 8 (for testing purpose)
🚀 Installation :
-
Via composer :
- for testing
🎉 Write your first command
- create a
commands.phpfile. - create a
consofile (you can change the name as you like). - include your
commands.phpfile intoconsoexecutable file. - it should look something like this.
:star: Available config methods :
-
now define a new
testcommand in yourcommands.php: - now your command has been registered.
- run
php conso --commandsor./conso --commandsin your terminal and you should see your command.

- command test is registered now (no description is shown you can add this later on).
- run your command
php conso testor./conso test.

:star: Add description
->description(string $description);

:star: Define sub commands
->sub(string|array $subCommand);


:star: Define command flags
- you can define flags using the flag method
->flags(string|array $flag) - this is a list of reserved flags
['-h', '--help', '-v', '--version', '-c', '--commands', '-q', '--quiet', '--ansi', '--no-ansi'] - for debug you can use
-vv or --verboseflags to get more details about the error - you can also pass values to flags
--flag=valueor-f=value

:star: Add command alias
- you can add an alias to a command with the alias method
->alias(string $alias)

:star: Define command help
- you can add help instructions to a command using the help method
->help(array $help) - command help can be displayed using the
-hor--helpflags - help array must be an array of sub commands, options and flags with their descriptions

:star: Group commands
- you can group commands using the
group()method

:star: Class commands
- class commands are very helpful for big commands
- first you need to create an
app/Commandsfolder. - you can also move your commands definitions file
commands.phptoappfolder to clean up things. - don't forget to autoload your commands with composer
psr-4{ "App\\" : "app" } -
now you need add commands paths and namespaces to conso to allow the build in command (command) to automatically create commands for you.
- to create a class command run
php conso command:make {command name} - for example lets create a test class command
php conso command:make test -
this will generate a
Testcommand class like this: -
now you need to register this command in your
commands.phpfile: - by default
testcommand will run theexecutemethod if no sub command is provided - each sub command is a separate method
:star: Accessing app from commands :
-
from a callback command
- from a class command
:star: Commands namespace
- you can wrap commands in the same namespace with
namespace()method which makes things cleaner
:star: Http support
- you can invoke conso from the browser or any http client just by passing commands to the input instance
:star: Compile your app to an executable shareable single .phar file :
- you can use this feature from version
2.0and above. - to compile your application and create a shareable
.pharfile use the built incompilecommand. - run
php conso compile:initto create aconso.jsonbuild file.

-
this will generate a json file like follow:
-
your stub file should look something like this:
- now you can run
php conso compileand you will get your package compiled to apharfile.

- you can use
--no-shebangflag to avoid adding shebang to yourpharfile (this is useful if you want to invoke yourpharfile fromhttp)
:star: Testing helpers:
- you can use
Conso\Testing\TestCasetest helper class for testing which helps you to :- turn on testing mode for you (return results instead of outputing to STDOUT).
- disable ansi colors which is not needed when testing.
✨ Todo
- improve code quality.
✨ Contributing
Thank you for considering to contribute to Conso. All the contribution guidelines are mentioned Here.
💖 Support
If this project helped you reduce time to develop, you can give me a cup of coffee :) : Paypal.
✨ License
Conso is an open-source software licensed under the MIT license.