2017 © Pedro Peláez
 

library jconsole

Useful Cli tools for Joomla CMS

image

asika/jconsole

Useful Cli tools for Joomla CMS

  • Friday, March 11, 2016
  • by asika32764
  • Repository
  • 1 Watchers
  • 2 Stars
  • 84 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 14 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

JConsole

An useful console tools for Joomla CMS

JConsole is a cli tools implement from Joomla Console Package. It provides an interface to create nested commands., (*1)

About Console package:, (*2)

Please see: https://github.com/asika32764/joomla-framework/tree/console/src/Joomla/Console, (*3)

Note: Console package has not added to Joomla Framework yet, it is an experimental package., (*4)

Installation via Composer

``` bash cd your/joomla/path, (*5)

php composer.phar create-project asika/jconsole libraries/jconsole 1.0.*, (*6)


Then, remove `libraries/jconsole/.gitignore` if you want to track whole Joomla by Git, use root gitignore instead. ## Getting started Open terminal, go to `path/of/joomla`. Type: ``` bash php cli/console

Will get a help message:, (*7)

Joomla! Console - version: 1.0
------------------------------------------------------------

[console Help]


Usage:
  console <command> [option]


Options:

  -h | --help       Display this help message.
  -q | --quiet      Do not output any message.
  -v | --verbose    Increase the verbosity of messages.
  --no-ansi         Suppress ANSI colors on unsupported terminals.


Available commands:

  help      List all arguments and show usage & manual.

  build     Some useful tools for building system.

  sql       Example description.

  system    System control.

Welcome to Joomla! Console.

Available Commands

  help                   List all arguments and show usage & manual.

  build                  Some useful tools for building system.
      check-constants    Check php files which do not included Joomla constants.
      gen-command        Generate a command class.
      index              Create empty index.html files in directories.

  sql                    SQL migration tools.
      backup             Backup sql.
      col                Column operation
      export             Export sql.
      import             Import a sql file.
      profile            Profiles.
      restore            Restore to pervious point.
      table              Model operation.

  system                 System control.
      clean-cache        Clean system cache.
      off                Set this site offline.
      on                 Set this site online.

Add your own Commands

Use Plugin

Create a plugin in console group., (*8)

``` php <?php, (*9)

// no direct access defined('_JEXEC') or die;, (*10)

class plgConsoleMycommand extends JPlugin { /** * onConsoleLoadCommand Event, called when auto added command. * * @param string $context The command class, example: 'Command\Build\Indexmaker'. * @param JConsole\Command\JCommand $command The parent command, You can addArgument to it. * * @return void */ public function onConsoleLoadCommand($context, $command) { if ($context != 'Command\System\System') { return; }, (*11)

    /** @var $command JCommand */
    $command->addArgument(
        'mycommand',             // Command name
        'This is my command.',   // Description
        null,                    // Options

        // Executing code.
        function($command)
        {
            $command->out('Hello World');
        }
    );
}

}, (*12)


Now, this custom command will added to system command.

Joomla! Console - version: 1.0

[system Help], (*13)

System control., (*14)

Usage: system [option], (*15)

Options: -h | --help Display this help message. -q | --quiet Do not output any message. -v | --verbose Increase the verbosity of messages. --no-ansi Suppress ANSI colors on unsupported terminals., (*16)

Available commands: mycommand This is my command. <---- Here is your command clean-cache Clean system cache. off Set this site offline. on Set this site online., (*17)


We execute it. ``` bash $ php cli/console system mycommand

Result, (*18)

$ php console system mycommand
Hello World

Use custom Command class

We can put our commands in plugin folder:, (*19)

plugins/system/mycomnand
    |---  Command
    |        |--- MyCommand
    |                |--- MyCommand.php  <--- Here is our command class
    |
    |---  mycommand.php
    |---  mycommand.xml

Create your command class., (*20)

``` php <?php namespace Command\Mycommand;, (*21)

use JConsole\Command\JCommand;, (*22)

class Mycommand extends JCommand { /** * An enabled flag. * * @var bool */ public static $isEnabled = true;, (*23)

protected $name = 'mycommand';

protected $description = 'This is mycommand.';

protected function doExecute()
{
    $this->out('Hello World.');

    return;
}

}, (*24)


Register command in your plugin. ``` php public function onConsoleLoadCommand($context, $command) { if ($context != 'Command\\System\\System') { return; } // Add autoload to plugin folder JLoader::registerNamespace('Command', __DIR__); // Namespace 'Command\Mycommand\Mycommand` will auto match `Command/Mycommand/Mycommand.php` path. $command->addArgument(new Command\Mycommand\MyCommand); }

This result will be same as previous section., (*25)

How to use Command class

Please see: https://github.com/asika32764/joomla-framework/tree/console/src/Joomla/Console, (*26)

And: https://github.com/asika32764/joomla-framework/tree/console/src/Joomla/Console/Command, (*27)

Todo

  1. SQL migration documentation.
  2. Site Installation
  3. Assets tools
  4. ACL fixer

Contribution

Welcome any Pull-request., (*28)

The Versions

11/03 2016

dev-staging

dev-staging

Useful Cli tools for Joomla CMS

  Sources   Download

The Requires

 

by Simon Asika

11/03 2016

1.0.9

1.0.9.0

Useful Cli tools for Joomla CMS

  Sources   Download

The Requires

 

by Simon Asika

31/07 2015

dev-master

9999999-dev

Useful Cli tools for Joomla CMS

  Sources   Download

The Requires

 

by Simon Asika

31/07 2015

1.0.8

1.0.8.0

Useful Cli tools for Joomla CMS

  Sources   Download

The Requires

 

by Simon Asika

07/08 2014

1.0.7

1.0.7.0

Useful Cli tools for Joomla CMS

  Sources   Download

The Requires

 

by Simon Asika

16/06 2014

1.0.6

1.0.6.0

Useful Cli tools for Joomla CMS

  Sources   Download

The Requires

 

by Simon Asika

17/04 2014

1.0.5

1.0.5.0

Useful Cli tools for Joomla CMS

  Sources   Download

The Requires

 

by Simon Asika

12/04 2014

1.0.4

1.0.4.0

Useful Cli tools for Joomla CMS

  Sources   Download

The Requires

 

by Simon Asika

24/02 2014

1.0.3

1.0.3.0

Useful Cli tools for Joomla CMS

  Sources   Download

The Requires

 

by Simon Asika

22/02 2014

1.0.2

1.0.2.0

Useful Cli tools for Joomla CMS

  Sources   Download

The Requires

 

by Simon Asika

19/02 2014

1.0.1

1.0.1.0

Useful Cli tools for Joomla CMS

  Sources   Download

The Requires

 

by Simon Asika

17/02 2014

1.0.0

1.0.0.0

Useful Cli tools for Joomla CMS

  Sources   Download

The Requires

 

by Simon Asika