some fix
This commit is contained in:
22
console/CgMigrationCreator.php
Normal file
22
console/CgMigrationCreator.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace core\console;
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\MigrationCreator;
|
||||
|
||||
class CgMigrationCreator extends MigrationCreator
|
||||
{
|
||||
|
||||
/**
|
||||
* Get the path to the stubs.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function stubPath()
|
||||
{
|
||||
return ROOT_DIR . '/core/console/migrations/stubs';
|
||||
}
|
||||
|
||||
}
|
48
console/ConsoleApp.php
Executable file
48
console/ConsoleApp.php
Executable file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace core\console;
|
||||
|
||||
|
||||
use core\App;
|
||||
use core\Database;
|
||||
use Phroute\Phroute\Dispatcher;
|
||||
|
||||
class ConsoleApp extends App
|
||||
{
|
||||
public $argv;
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->setMods();
|
||||
if(!$rout = $this->getRout()){
|
||||
echo "Not found \n";
|
||||
exit();
|
||||
}
|
||||
App::$db = new Database();
|
||||
$dispatcher = new Dispatcher(App::$collector->getData());
|
||||
$response = $dispatcher->dispatch('GET', $rout);
|
||||
echo $response;
|
||||
}
|
||||
|
||||
public function setArgv($argv)
|
||||
{
|
||||
$this->argv = $argv;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function getRout()
|
||||
{
|
||||
if(isset($this->argv[1])){
|
||||
return $this->argv[1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function start()
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
|
||||
}
|
30
console/ConsoleController.php
Executable file
30
console/ConsoleController.php
Executable file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace core\console;
|
||||
|
||||
|
||||
use samejack\PHP\PHP_ArgvParser;
|
||||
|
||||
class ConsoleController
|
||||
{
|
||||
/**
|
||||
* @var Out
|
||||
*/
|
||||
public $out;
|
||||
protected $argv;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->out = new Out();
|
||||
$argv = $_SERVER['argv'];
|
||||
unset($argv[0]);
|
||||
unset($argv[1]);
|
||||
if(!empty($argv)){
|
||||
$argvParser = new PHP_ArgvParser();
|
||||
$tmp = implode(" ", $argv);
|
||||
$this->argv = $argvParser->parseConfigs($tmp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
78
console/Out.php
Executable file
78
console/Out.php
Executable file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace core\console;
|
||||
|
||||
|
||||
class Out
|
||||
{
|
||||
private $foreground_colors = array();
|
||||
private $background_colors = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Set up shell colors
|
||||
$this->foreground_colors['black'] = '0;30';
|
||||
$this->foreground_colors['dark_gray'] = '1;30';
|
||||
$this->foreground_colors['blue'] = '0;34';
|
||||
$this->foreground_colors['light_blue'] = '1;34';
|
||||
$this->foreground_colors['green'] = '0;32';
|
||||
$this->foreground_colors['light_green'] = '1;32';
|
||||
$this->foreground_colors['cyan'] = '0;36';
|
||||
$this->foreground_colors['light_cyan'] = '1;36';
|
||||
$this->foreground_colors['red'] = '0;31';
|
||||
$this->foreground_colors['light_red'] = '1;31';
|
||||
$this->foreground_colors['purple'] = '0;35';
|
||||
$this->foreground_colors['light_purple'] = '1;35';
|
||||
$this->foreground_colors['brown'] = '0;33';
|
||||
$this->foreground_colors['yellow'] = '1;33';
|
||||
$this->foreground_colors['light_gray'] = '0;37';
|
||||
$this->foreground_colors['white'] = '1;37';
|
||||
|
||||
$this->background_colors['black'] = '40';
|
||||
$this->background_colors['red'] = '41';
|
||||
$this->background_colors['green'] = '42';
|
||||
$this->background_colors['yellow'] = '43';
|
||||
$this->background_colors['blue'] = '44';
|
||||
$this->background_colors['magenta'] = '45';
|
||||
$this->background_colors['cyan'] = '46';
|
||||
$this->background_colors['light_gray'] = '47';
|
||||
}
|
||||
|
||||
// Returns colored string
|
||||
public function get($string, $foreground_color = null, $background_color = null)
|
||||
{
|
||||
$colored_string = "";
|
||||
|
||||
// Check if given foreground color found
|
||||
if (isset($this->foreground_colors[$foreground_color])) {
|
||||
$colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m";
|
||||
}
|
||||
// Check if given background color found
|
||||
if (isset($this->background_colors[$background_color])) {
|
||||
$colored_string .= "\033[" . $this->background_colors[$background_color] . "m";
|
||||
}
|
||||
|
||||
// Add string and end coloring
|
||||
$colored_string .= $string . "\033[0m";
|
||||
|
||||
return $colored_string;
|
||||
}
|
||||
|
||||
public function r($string, $foreground_color = null, $background_color = null)
|
||||
{
|
||||
echo $this->get($string, $foreground_color, $background_color) . "\n";
|
||||
}
|
||||
|
||||
// Returns all foreground color names
|
||||
public function getForegroundColors()
|
||||
{
|
||||
return array_keys($this->foreground_colors);
|
||||
}
|
||||
|
||||
// Returns all background color names
|
||||
public function getBackgroundColors()
|
||||
{
|
||||
return array_keys($this->background_colors);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user