Componette

Componette

Joseki

Joseki / Console v0.2.2

Simple Symfony Console integration to Nette Framework

download-cloud-line composer require joseki/console

Joseki/Console

Build Status Latest Stable Version

Requirements

Joseki/Console requires PHP 5.4 or higher.

Installation

The best way to install Joseki/Console is using Composer:

$ composer require joseki/console

Setup

  • create file e.g. app/console with the following content:
#!/usr/bin/env php
<?php
/** @var Nette\DI\Container $container */
$container = require __DIR__ . '/bootstrap.php';
$application = $container->getService('Console.cli');
$application->run();
  • register compiler extension in your config.neon:
extensions:
  Console: Joseki\Console\DI\ConsoleExtension
  • profit

Usage

Your console commands can be added via config.neon as a service with a joseki.console.command tag:

services:
  - class: Your\Own\Command
    tags: ['joseki.console.command']

or your can directly register it under Console compiler extension:

Console:
  commands:
    - Your\Own\Command

Running a console command

app/console yourCommandName

Too many commands? Long command names (including namespaces)?

Split your commands by their namespaces into separate console scripts. Separate your cron script from your database generators or migrations or whatever groups of commands you have. Simply register your console alias and namespace prefix of you commands group as follows:

Console:
  console:
    cron: 'myapp:crons'       # accepts only commands from 'myapp:crons' namespace, eg. 'myapp:crons:emails'

Then create a new console file bin/cron:

#!/usr/bin/env php
<?php
/** @var Nette\DI\Container $container */
$container = require __DIR__ . '/bootstrap.php';
$application = $container->getService('Console.console.cron');
$application->run();

and run your commands with suffix name only. Compare old:

app/console myapp:crons:emails

with newly created way:

app/cron emails
  • v0.2.2 Released version 0.2.2

  • v0.2.1 Released version 0.2.1

    • fixed fallback for list and help commands
  • v0.2 Released version 0.2

    • added clever console
    • removed unused dependency on config
    • code reformated
    • all commands also get a tag for Kdyby/Console
  • v0.1.1 Released version 0.1.1

    • fixed DI extension default value for commands
  • v0.1 Released version 0.1

    This a first stable release.
    This tool allows you to use Symfony/Console with Nette Framework applications.

price-tag-2-line

Badges

guide-fill

Dependencies

php (>= 5.4.0)
nette/di (~2.3)
Componette Componette felix@nette.org