Skip to content

Commit

Permalink
console support
Browse files Browse the repository at this point in the history
  • Loading branch information
dracony committed Sep 1, 2016
1 parent 17831dd commit d7068c0
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
9 changes: 9 additions & 0 deletions bundles/app/src/Project/App/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ protected function buildORMWrappers()
return new ORMWrappers($this);
}

/**
* Build Console command registry
* @return ConsoleCommands
*/
protected function buildConsoleProvider()
{
return new Console($this);
}

/**
* Get bundle root directory
* @return string
Expand Down
34 changes: 34 additions & 0 deletions bundles/app/src/Project/App/Console.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Project\App;

class Console extends \PHPixie\DefaultBundle\Console
{
/**
* @var Builder
*/
protected $builder;

/**
* Constructor
* @param Builder $builder
*/
public function __construct($builder)
{
$this->builder = $builder;
}

public function commandNames()
{
return array('greet');
}

/**
* Build 'greet' command
* @return ConsoleCommands\Greet
*/
protected function buildGreetCommand($commandConfig)
{
return new Console\Greet($commandConfig);
}
}
23 changes: 23 additions & 0 deletions bundles/app/src/Project/App/Console/Greet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Project\App\Console;

class Greet extends \PHPixie\Console\Command\Implementation
{
public function __construct($config)
{
$config
->description('Greet the user');

$config->argument('message')
->description("Message to display");

parent::__construct($config);
}

public function run($argumentData, $optionData)
{
$message = $argumentData->get('message', "Have fun coding!");
$this->writeLine($message);
}
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
}
},
"require": {
"phpixie/default-bundle": "~3.1",
"phpixie/bundle-framework": "~3.1"
"phpixie/default-bundle": "~3.6",
"phpixie/bundle-framework": "~3.2",
},
"require-dev": {
"phpixie/test": "~3.0"
Expand Down
9 changes: 9 additions & 0 deletions console
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/php
<?php

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

$framework = new Project\Framework();
$framework->registerDebugHandlers();
$exitCode = $framework->processConsoleSapiCommand();
exit($exitCode);

0 comments on commit d7068c0

Please sign in to comment.