Skip to content

Commit

Permalink
added console capabilities through dot-console
Browse files Browse the repository at this point in the history
  • Loading branch information
n3vrax authored and n3vrax committed May 27, 2017
1 parent f3ce3aa commit f267f42
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 25 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
## 0.4.0 - 2017-05-27

### Changed
* Nothing

### Added
* console capabilities added through dot-console based on zf-console
* bin/console.php bootstrap file(e.g php bin/console.php <command_name>)
* see [zf-console documentation](https://github.com/zfcampus/zf-console) for details on how to use console

### Deprecated
* Nothing

### Removed
* Nothing

### Fixed
* Nothing


## 0.3.1 - 2017-04-07

### Changed
Expand Down
22 changes: 22 additions & 0 deletions bin/console.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Console application bootstrap file
*/
use ZF\Console\Application;

chdir(dirname(__DIR__));
require 'vendor/autoload.php';

/**
* Self-called anonymous function that creates its own scope and keep the global namespace clean.
*/
call_user_func(function () {
/** @var \Interop\Container\ContainerInterface $container */
$container = require 'config/container.php';

/** @var Application $app */
$app = $container->get(Application::class);

$exit = $app->run();
exit($exit);
});
52 changes: 27 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,18 @@
},
"require": {
"php": "^7.1",
"roave/security-advisories": "dev-master",
"zendframework/zend-expressive": "^2.0.2",
"zendframework/zend-expressive-fastroute": "^2.0",
"zendframework/zend-expressive-twigrenderer": "^1.4",
"zendframework/zend-servicemanager": "^3.3.0",
"zendframework/zend-db": "^2.8",
"zendframework/zend-i18n": "^2.7",
"zendframework/zend-i18n-resources": "^2.5",
"zendframework/zend-captcha": "^2.6",
"zendframework/zendservice-recaptcha": "^3.0",
"zendframework/zend-text": "^2.6",
"zendframework/zend-stdlib": "^3.1",
"zendframework/zend-psr7bridge": "^0.2.2",
"zendframework/zend-config": "^3.1",
"zendframework/zend-config-aggregator": "^0.2.0",
"zendframework/zend-component-installer": "^1.0 || ^0.7.0",

"dotkernel/dot-annotated-services": "^1.1",
"dotkernel/dot-authentication-service": "^0.2",
"dotkernel/dot-authentication-web": "^0.2",
"dotkernel/dot-cache": "^1.1",
"dotkernel/dot-controller": "^0.3",
"dotkernel/dot-controller-plugin-flashmessenger": "^0.2",
"dotkernel/dot-console": "^0.1",
"dotkernel/dot-controller": "^0.2",
"dotkernel/dot-controller-plugin-authentication": "^0.2",
"dotkernel/dot-controller-plugin-authorization": "^0.2",
"dotkernel/dot-controller-plugin-flashmessenger": "^0.2",
"dotkernel/dot-controller-plugin-forms": "^0.2",
"dotkernel/dot-controller-plugin-mail": "^0.1",
"dotkernel/dot-controller-plugin-session": "^0.2",
"dotkernel/dot-mapper": "^0.4",
"dotkernel/dot-event": "^0.2",
"dotkernel/dot-filter": "^1.1",
"dotkernel/dot-flashmessenger": "^0.2",
Expand All @@ -52,14 +35,32 @@
"dotkernel/dot-inputfilter": "^1.1",
"dotkernel/dot-log": "^1.1",
"dotkernel/dot-mail": "^0.1",
"dotkernel/dot-mapper": "^0.3",
"dotkernel/dot-navigation": "^0.2",
"dotkernel/dot-paginator": "^1.1",
"dotkernel/dot-rbac": "^0.2",
"dotkernel/dot-rbac-guard": "^0.2",
"dotkernel/dot-session": "^2.0",
"dotkernel/dot-twigrenderer": "^0.2",
"dotkernel/dot-user": "^0.3",
"dotkernel/dot-validator": "^1.1"
"dotkernel/dot-user": "^0.2",
"dotkernel/dot-validator": "^1.1",

"roave/security-advisories": "dev-master",
"zendframework/zend-captcha": "^2.6",
"zendframework/zend-component-installer": "^1.0 || ^0.7.0",
"zendframework/zend-config": "^3.1",
"zendframework/zend-config-aggregator": "^0.2.0",
"zendframework/zend-db": "^2.8",
"zendframework/zend-expressive": "^2.0.2",
"zendframework/zend-expressive-fastroute": "^2.0",
"zendframework/zend-expressive-twigrenderer": "^1.4",
"zendframework/zend-i18n": "^2.7",
"zendframework/zend-i18n-resources": "^2.5",
"zendframework/zend-psr7bridge": "^0.2.2",
"zendframework/zend-servicemanager": "^3.3.0",
"zendframework/zend-stdlib": "^3.1",
"zendframework/zend-text": "^2.6",
"zendframework/zendservice-recaptcha": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0.8 || ^5.7.15",
Expand All @@ -72,7 +73,8 @@
"psr-4": {
"Admin\\App\\": "src/App/src",
"Admin\\Admin\\": "src/Admin/src",
"Admin\\User\\": "src/User/src"
"Admin\\User\\": "src/User/src",
"Admin\\Console\\": "src/Console/src"
}
},
"autoload-dev": {
Expand Down Expand Up @@ -101,8 +103,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.3-dev",
"dev-develop": "0.4-dev"
"dev-master": "0.4-dev",
"dev-develop": "0.5-dev"
}
}
}
18 changes: 18 additions & 0 deletions config/autoload/console.global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

use Admin\Console\Command\HelloCommand;

return [
'dot_console' => [
//'name' => 'DotKernel Console',
//'version' => '1.0.0',

'commands' => [
[
'name' => 'hello',
'description' => 'Hello, World! command example',
'handler' => HelloCommand::class,
],
]
]
];
2 changes: 2 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@
\Dot\Twig\ConfigProvider::class,
\Dot\User\ConfigProvider::class,
\Dot\Validator\ConfigProvider::class,
\Dot\Console\ConfigProvider::class,

//application
\Admin\Admin\ConfigProvider::class,
\Admin\User\ConfigProvider::class,
\Admin\App\ConfigProvider::class,
\Admin\Console\ConfigProvider::class,

// Load application config in a pre-defined order in such a way that local settings
// overwrite global settings. (Loaded as first to last):
Expand Down
45 changes: 45 additions & 0 deletions src/Console/src/Command/HelloCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* @see https://github.com/dotkernel/admin/ for the canonical source repository
* @copyright Copyright (c) 2017 Apidemia (https://www.apidemia.com)
* @license https://github.com/dotkernel/admin/blob/master/LICENSE.md MIT License
*/

declare(strict_types=1);

namespace Admin\Console\Command;

use Dot\AnnotatedServices\Annotation\Service;
use Dot\Console\Command\AbstractCommand;
use Zend\Console\Adapter\AdapterInterface;
use ZF\Console\Route;

/**
* Class HelloCommand
* @package Admin\Console\Command
*
* @Service
*/
class HelloCommand extends AbstractCommand
{
/**
* @param Route $route
* @param AdapterInterface $console
* @return int
*/
public function __invoke(Route $route, AdapterInterface $console)
{
$console->writeLine(
<<<EOT
_ _ _ _ ____ _ _ __ _ _
| | | | ___| | | ___ | _ \ ___ | |_| |/ /___ _ __ _ __ ___| | | |
| |_| |/ _ \ | |/ _ \ | | | |/ _ \| __| ' // _ \ '__| '_ \ / _ \ | | |
| _ | __/ | | (_) | _ | |_| | (_) | |_| . \ __/ | | | | | __/ | |_|
|_| |_|\___|_|_|\___/ ( ) |____/ \___/ \__|_|\_\___|_| |_| |_|\___|_| (_)
|/
EOT
);
return 0;
}
}
29 changes: 29 additions & 0 deletions src/Console/src/ConfigProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* @see https://github.com/dotkernel/admin/ for the canonical source repository
* @copyright Copyright (c) 2017 Apidemia (https://www.apidemia.com)
* @license https://github.com/dotkernel/admin/blob/master/LICENSE.md MIT License
*/

declare(strict_types=1);

namespace Admin\Console;

/**
* Class ConfigProvider
* @package Admin\Console
*/
class ConfigProvider
{
public function __invoke()
{
return [
'dependencies' => $this->getDependencies(),
];
}

public function getDependencies()
{
return [];
}
}

0 comments on commit f267f42

Please sign in to comment.