jameslevi / atmos
Is a simple library for creating command line scripts in PHP.
Requires
- php: >=5.3.0
- jameslevi/stencil: ^1.0
This package is not auto-updated.
Last update: 2025-04-28 04:18:22 UTC
README
Is a simple library for creating command line scripts in PHP.
Features
- Create good looking PHP command line scripts.
- Built-in commands to make web development much easier.
- Easy integration with any PHP frameworks.
Installation
- You can install via composer.
composer require jameslevi/atmos
- Copy the atmos file from vendor/jameslevi/atmos to root directory.
- Create a new folder named commands in your root directory.
Getting Started
- Generate a new command file.
php atmos --make Test
- Open the generated PHP command file and write your code inside the main method.
/** * Method to be executed in the command line. * * @param array $arguments * @return void */ protected function main(array $arguments) { Console::log("Hello World!"); }
- Test the command.
php atmos test
Call Specific Methods
- Add new protected method in your command file. For this example let's say "generate".
/** * This method will generate new file. * * @param array $arguments * @return void */ protected function generate(array $arguments) { Console::success("File is generated."); }
- Call this method using this command.
php atmos test:generate
Arguments
- You can use parameters supplied from the command line.
/** * This method will generate new file. * * @param array $arguments * @return void */ protected function generate(array $arguments) { Console::success($arguments[0] . " file is generated."); }
- You can call this method using this command.
php atmos test:generate newfile.php
Alias
You can set an alias for your command by setting a protected variable named "alias" in the command class.
protected $alias = "alternative";
The command below will execute generate method.
php atmos --alternative:generate
Console Messages
- Log - Print a simple message.
Console::log("Hello World!");
- Success - Print a success message.
Console::success("Congratulations! you made it!");
- Error - Print an error message.
Console::error("Something went wrong!");
- Info - Print an info message.
Console::info("You scored 30 points!");
- Warning - Print a warning message.
Console::warn("I told you not to go here!");
Call Multiple Commands
Very useful if you want to call multiple commands in just a single command. The order of execution of each command depends on the order of values in array.
Console::call(array( 'composer -h', 'php atmos -h' ));
Start Built-in PHP Server
You can now start PHP server using atmos commands. This command will start the server at port 8080.
php atmos --serve 8080
Contribution
For issues, concerns and suggestions, you can email James Crisostomo via nerdlabenterprise@gmail.com.
License
This package is an open-sourced software licensed under MIT License.