From: Andrey Kutejko Date: Thu, 20 Jun 2013 22:32:50 +0000 (+0300) Subject: debug server and display routes commands X-Git-Tag: 0.5~222 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=28dfe6ec55167135be34e6be8aca59f059b8bc98;p=ipf.git debug server and display routes commands --- diff --git a/index.php b/index.php index 444325d..93fb5ce 100644 --- a/index.php +++ b/index.php @@ -2,9 +2,10 @@ // This is a index stub for a IPF Projects -$ipf_path = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'ipf'; -$project_path = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'project'; +$here = dirname(__FILE__); +$ipf_path = $here.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'ipf'; +$project_path = $here.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'project'; set_include_path(get_include_path() . PATH_SEPARATOR . $ipf_path . PATH_SEPARATOR . $project_path); require 'ipf.php'; -return IPF::boot($ipf_path, $project_path) && IPF_Project::getInstance()->run(); +return IPF::boot($ipf_path, $project_path, $here) && IPF_Project::getInstance()->run(); diff --git a/ipf.php b/ipf.php index 3281b9f..2edf6c8 100644 --- a/ipf.php +++ b/ipf.php @@ -112,13 +112,14 @@ final class IPF return is_file($path); } - public static function boot($ipf_path, $project_path) + public static function boot($ipf_path, $project_path, $document_root) { if (php_sapi_name() === 'cli-server' && IPF::requestedFileExists()) return false; IPF::$settings['ipf_path'] = $ipf_path; IPF::$settings['project_path'] = $project_path; + IPF::$settings['document_root'] = $document_root; try { IPF::loadSettings(); diff --git a/ipf/cli.php b/ipf/cli.php index 37c5f1a..eff7869 100644 --- a/ipf/cli.php +++ b/ipf/cli.php @@ -7,6 +7,8 @@ class IPF_Cli public function __construct() { $this->commands = array( + new IPF_Command_DebugServer, + new IPF_Command_Routes, new IPF_Command_BuildModels, new IPF_Command_BuildContribModels, new IPF_Command_Sql, @@ -29,15 +31,15 @@ class IPF_Cli print "Usage: php index.php [options] [args]\n\n"; print "Available subcommands:\n"; - $firstColumnSize = 7; - foreach ($this->commands as $command) { - $l = strlen($command->command); - if ($l > $firstColumnSize) - $firstColumnSize = $l; - } - foreach ($this->commands as $command) { - print ' '.str_pad($command->command, $firstColumnSize) . "\t" . $command->description . "\n"; - } + $rows = array(); + foreach ($this->commands as $command) + $rows[] = array( + ' ' . $command->command, + $command->description, + ); + + IPF_Shell::displayTwoColumns($rows); + print "\n"; } diff --git a/ipf/command/debugserver.php b/ipf/command/debugserver.php new file mode 100644 index 0000000..07bc79e --- /dev/null +++ b/ipf/command/debugserver.php @@ -0,0 +1,14 @@ + $firstColumnSize) + $firstColumnSize = $l; + } + if ($firstColumnSize > $firstColumnMax) + $firstColumnSize = $firstColumnMax; + foreach ($rows as $row) { + echo str_pad($row[0], $firstColumnSize) . "\t" . $row[1] . "\n"; + } + } }