Giter Site home page Giter Site logo

cilex's Introduction

Cilex, a simple Command Line Interface framework

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

  1. git clone this repository.
  2. Download composer: curl -s https://getcomposer.org/installer | php
  3. 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

cilex's People

Contributors

beberlei avatar benmatselby avatar beshkenadze avatar christiaan avatar cs278 avatar davedevelopment avatar debo avatar henrikbjorn avatar hgraca avatar liuggio avatar lsmith77 avatar mvriel avatar ninsuo avatar nyholm avatar proofek avatar pulse00 avatar seldaek avatar sgoettschkes avatar simensen avatar stof avatar till avatar tommygnr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cilex's Issues

compilation error

When I try to compile:

cilex/bin$ php ./compile

PHP Fatal error: Uncaught exception 'RuntimeException' with message 'The git binary cannot be found.' in /media/disk2/darek/yii/cilex/src/Cilex/Compiler.php:43
Stack trace:
#0 /media/disk2/darek/yii/cilex/bin/compile(13): Cilex\Compiler->compile()
#1 {main}

thrown in /media/disk2/darek/yii/cilex/src/Cilex/Compiler.php on line 43

Fatal error: Uncaught exception 'RuntimeException' with message 'The git binary cannot be found.' in /media/disk2/darek/yii/cilex/src/Cilex/Compiler.php on line 43

RuntimeException: The git binary cannot be found. in /media/disk2/darek/yii/cilex/src/Cilex/Compiler.php on line 43

but git is of course available on system

cilex/bin$ whereis git
git: /usr/bin/git /usr/bin/X11/git /usr/share/man/man1/git.1.gz

cilex/bin$ git
usage: git [--version] [--exec-path[=]] [--html-path] [--man-path] [--info-path]
[-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
[--git-dir=] [--work-tree=] [--namespace=]
[-c name=value] [--help]
[]

ReadTheDocs.org

In order to always provide up to date documentation we should consider using readthedocs.org to auto compile our sphinx documentation.

Add dependency support for pimple ~2.0

Cilex is currently bound to pimple ~1.0. When included in a complex composer.json dependency tree, cilex bounds pimple to the older version. This is causing problems with a variety of other packages, such as elasticsearch.

Dependency issues with latest pimple v1.1.x

I have the latest stable version of pimple 1.1.1 as a dependency in one of my packages.
I'm getting the following error when running composer update after adding "cilex/cilex": "1.0.*@dev" to the list of required dependencies:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install cilex/cilex 1.0.1
    - Conclusion: don't install pimple/pimple v1.0.2
    - Conclusion: remove pimple/pimple v1.1.1
    - Installation request for cilex/cilex ~1.0 -> satisfiable by cilex/cilex[1.0.0, 1.0.1].
    - vendor/my-project v1.1.1 requires pimple/pimple 1.1.* -> satisfiable by pimple/pimple[v1.1.1, v1.1.0].
    - vendor/my-project v1.0.1 requires pimple/pimple 1.1.* -> satisfiable by pimple/pimple[v1.1.1, v1.1.0].
    - vendor/my-project v1.1.0 requires pimple/pimple 1.1.* -> satisfiable by pimple/pimple[v1.1.1, v1.1.0].
    - vendor/my-project v1.1.0 requires pimple/pimple 1.1.* -> satisfiable by pimple/pimple[v1.1.1, v1.1.0].
    - Can only install one of: pimple/pimple[v1.1.0, 1.0.0].
    - Can only install one of: pimple/pimple[v1.1.1, 1.0.0].
    - cilex/cilex 1.0.0 requires pimple/pimple 1.0.* -> satisfiable by pimple/pimple[1.0.0, v1.0.1, v1.0.2].
    - Conclusion: don't install pimple/pimple v1.0.1
    - Installation request for vendor/my-project ~1.0,>=1.0.1 -> satisfiable by vendor/my-project[v1.1.0, v1.1.1, v1.0.1].

Cilex/Silex ServiceProvider Incompatibility

The register function of Cilex\Application supposedly allows you to register a Silex ServiceProvider (\vendor\cilex\cilex\src\Cilex\Application.php:97-99), but when actually trying to register the Silex ServiceProvider, you hit:

Catchable fatal error: Argument 1 passed to Igorw\Silex\ConfigServiceProvider::register() must be an instance of Silex\Application, instance of Cilex\Application given

If it is to be compatible with Silex service providers, the Interface definition typehint must be dropped or if it is not compatible, lines \vendor\cilex\cilex\src\Cilex\Application.php:97-103 should be removed.

This seems related to #3.

Nested commands

Hi,
Is there a way to call one command from another or to create a batch of commands?

Is this package still being maintained ?

Is this package still being maintained ? Or do the developers suggest to use something else ?
E.g. would it help to aid in development, testing, updating dependancies etc ?

ServiceProviderInterface and Silex

so one of my visions was that Cilex and Silex could share extensions. right now @mvriel introduced a new ServiceProviderInterface interface inside the Cilex namespace. i talked briefly with him on IRC today where @mvriel said he wants to switch the Silex one, which obviously would imply a dependency on Silex, which imho is fine, but i don't know how specifically he wants it to play out given the Application type hint.

but it does raise the question of if we are not making things needlessly complex by not doing this all inside Silex. then again doing it all inside Silex would go against the entire "micro" idea. so maybe we do need to ask the Silex guys to make things a bit easier for us ..

/cc @igorw @jmikola

Update the download link for box

The current download link for box is broken please update it with the correct link:

curl -LSs https://box-project.github.io/box2/installer.php | php

ClosureCommand or another easy way to add new commands

As a developer, frequent tooling is required for automation of simple tasks, so I want to be more effective in writing those and spend less lines on getting thing done::

$app = require 'cilex.phar';
$app->simpleCommand('greet', function($name) {
     return "Hello, $name!\n";
})->run();

Changing Output, and Input

Hello,
In order to add functional tests I was thinking to change the output and check the output stream (as I do on sf2),
In the Symfony\Component\Console\Application
the run function has public function run(InputInterface $input = null, OutputInterface $output = null)
but the approach is different in Cilex, and I'm not able to change Input and output.

How do you suggest me to do it?

Replace PharCompiler with box-project

To improve the creation of the phar file we should replace our custom compiler with that of box-project. This will reduce the maintenance necessary and eliminate possible bugs thanks to a tried system

Impossible install branch develop


  Problem 1
    - silex/api 2.0.x-dev requires pimple/pimple ~2.1 -> satisfiable by pimple/pimple[v2.1.0, v2.1.1].
    - Can only install one of: pimple/pimple[v3.0.0, v2.1.0].
    - Can only install one of: pimple/pimple[v3.0.0, v2.1.1].
    - cilex/cilex dev-develop requires pimple/pimple 3.0.0 as 2.1.0 -> satisfiable by pimple/pimple[v3.0.0].
    - cilex/cilex dev-develop requires silex/api 2.0.x-dev -> satisfiable by silex/api[2.0.x-dev].
    - Installation request for cilex/cilex dev-develop -> satisfiable by cilex/cilex[dev-develop].

Move to Pimple 2.*

Want to use Pimple 2.* in my application but composer seeing conflict with Cilex and doesn't let me. This is also providing the use of PhpDocumentor since it uses Cilex as well. Have NOT looked to see what all changes were make on Pimple but always prefer using most up to date versions when possible. After a quick look it looks like the main change is that instances are shared by default like share() would do and you use factory() to get something like the old behavior if my reading of the code is right. Not sure how this effects Cilex.

Need new label

I need new label for delete this error

Deprecated: The TableHelper class was deprecated in version 2.5 and will be removed in 3.0. Use Symfony\Component\Console\Helper\Table instead. in/vendor/symfony/console/Symfony/Component/Console/Helper/TableHelper.php on line 38

PHP warning from constructor

The error:

Warning: array_key_exists() expects parameter 2 to be array, null given in /vendor/pimple/pimple/lib/Pimple.php on line 95

Call Stack:
    0.0007     627856   1. {main}() /some/path:0
    0.0032     795288   2. Cilex\Application->__construct() /some/path:6
    0.0037     804696   3. Cilex\Application->register() /vendor/cilex/cilex/src/Cilex/Application.php:43
    0.0037     804696   4. Cilex\Provider\Console\ConsoleServiceProvider->register() /vendor/cilex/cilex/src/Cilex/Application.php:99
    0.0041     820256   5. Cilex\Provider\Console\BaseConsoleServiceProvider->register() /vendor/cilex/console-service-provider/src/Cilex/Provider/Console/ConsoleServiceProvider.php:30
    0.0041     820968   6. Pimple->offsetExists() /vendor/cilex/console-service-provider/src/Cilex/Provider/Console/ConsoleServiceProvider.php:27
    0.0041     821016   7. array_key_exists() /vendor/pimple/pimple/lib/Pimple.php:95

The code:

#!/usr/bin/env php
<?php

require_once(__DIR__.'/../vendor/autoload.php');

$app = new \Cilex\Application('Chat');
$app->command(new \Cilex\Command\GreetCommand());
$app->run();

The usage:

/path/to/file demo:greet Mark

The fix:

Looks like Pimple isn't getting initialized correctly. So, parent::__construct(); should be called first thing in Cilex\Application::__construct() This is similar to how Silex works when it extends Pimple.

cilex.phar has errors

Fresh install:
1008 git clone https://github.com/Cilex/Cilex.git
1009 cd Cilex
1010 composer update
1011 composer install
1012 php bin/compile
1013 php cilex.phar
PHP Warning: require(phar:///private/tmp/Cilex/cilex.phar/vendor/composer/include_paths.php): failed to open stream: phar error: "vendor/composer/include_paths.php" is not a file in phar "/private/tmp/Cilex/cilex.phar" in phar:///private/tmp/Cilex/cilex.phar/vendor/composer/autoload_real.php on line 29

Warning: require(phar:///private/tmp/Cilex/cilex.phar/vendor/composer/include_paths.php): failed to open stream: phar error: "vendor/composer/include_paths.php" is not a file in phar "/private/tmp/Cilex/cilex.phar" in phar:///private/tmp/Cilex/cilex.phar/vendor/composer/autoload_real.php on line 29
PHP Fatal error: require(): Failed opening required 'phar:///private/tmp/Cilex/cilex.phar/vendor/composer/include_paths.php' (include_path='.:') in phar:///private/tmp/Cilex/cilex.phar/vendor/composer/autoload_real.php on line 29

Fatal error: require(): Failed opening required 'phar:///private/tmp/Cilex/cilex.phar/vendor/composer/include_paths.php' (include_path='.:') in phar:///private/tmp/Cilex/cilex.phar/vendor/composer/autoload_real.php on line 29

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.