-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added console capabilities through dot-console
- Loading branch information
n3vrax
authored and
n3vrax
committed
May 27, 2017
1 parent
f3ce3aa
commit f267f42
Showing
7 changed files
with
163 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
], | ||
] | ||
] | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 []; | ||
} | ||
} |