cilex / cilex
The PHP micro-framework for Command line tools based on the Symfony2 Components
Installs: 3 091 601
Dependents: 31
Suggesters: 1
Security: 0
Stars: 620
Watchers: 29
Forks: 68
Open Issues: 6
Requires
- php: >=5.5.9
- pimple/pimple: ^3.0
- silex/api: ^2.0
- symfony/console: ^2.7 || ^3.0
- symfony/event-dispatcher: ^2.7 || ^3.0
- symfony/process: ^2.7 || ^3.0
Requires (Dev)
- phpunit/phpunit: ~3.7
Suggests
- symfony/validator: ^2.7 || ^3.0
- symfony/yaml: ^2.7 || ^3.0
This package is auto-updated.
Last update: 2024-09-22 05:05:59 UTC
README
Cilex is a simple command line application framework to develop simple tools based on Symfony2 components:
<?php if (!$loader = include __DIR__.'/vendor/autoload.php') { die('You must set up the project dependencies.'); } $app = new \Cilex\Application('Cilex'); $app->command(new \Cilex\Command\GreetCommand()); $app->command('foo', function ($input, $output) { $output->writeln('Example output'); }); $app->run();
Cilex works with PHP 5.5.9 or later and is heavily inspired by the Silex web micro-framework by Fabien Potencier.
Installation
git clone
this repository.- Download composer:
curl -s https://getcomposer.org/installer | php
- Install Cilex' dependencies:
php composer.phar install
Usage
- Create your new commands in
src/Cilex/Command/
- Add your new commands to
bin/run.php
- Run the commands as:
./bin/run.php demo:greet world ./bin/run.php demo:greet world -y ./bin/run.php demo:greet world --yell ./bin/run.php demo:info
Creating a PHAR
- Download and install box:
curl -LSs https://box-project.github.io/box2/installer.php | php
chmod +x box.phar
mv box.phar /usr/local/bin/box
- Update the project phar config in box.json
- Create the package:
box build
- Run the commands:
./cilex.phar demo:greet world ./cilex.phar demo:greet world -y ./cilex.phar demo:greet world --yell ./cilex.phar demo:info
- enjoy a lot.
License
Cilex is licensed under the MIT license.
FAQ
Q: How do I pass configuration into the application?
A: You can do this by adding the following line, where $configPath is the path to the configuration file you want to use:
$app->register(new \Cilex\Provider\ConfigServiceProvider(), array('config.path' => $configPath));
The formats currently supported are: YAML, XML and JSON