本文整理汇总了PHP中Cml\Config::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::load方法的具体用法?PHP Config::load怎么用?PHP Config::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cml\Config
的用法示例。
在下文中一共展示了Config::load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* 从注释解析生成文档
*
*/
public static function parse()
{
$result = [];
$config = Config::load('api', Cml::getApplicationDir('app_controller_path') ? true : false);
foreach ($config['version'] as $version => $apiList) {
isset($result[$version]) || ($result[$version] = []);
foreach ($apiList as $model => $api) {
$pos = strrpos($api, '\\');
$controller = substr($api, 0, $pos);
$action = substr($api, $pos + 1);
if (class_exists($controller) === false) {
continue;
}
$annotationParams = self::getAnnotationParams($controller, $action);
empty($annotationParams) || ($result[$version][$model] = $annotationParams);
}
}
foreach ($result as $key => $val) {
if (count($val) < 1) {
unset($result[$key]);
}
}
$systemCode = Cml::requireFile(__DIR__ . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR . 'code.php');
Cml::requireFile(__DIR__ . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR . 'doc.html', ['config' => $config, 'result' => $result, 'systemCode' => $systemCode]);
}
示例2: parse
/**
* 从注释解析生成文档
*
*/
public static function parse()
{
$result = array();
$config = Config::load('api', false);
foreach ($config['version'] as $version => $apiList) {
isset($result[$version]) || ($result[$version] = array());
foreach ($apiList as $model => $api) {
$pos = strrpos($api, '\\');
$controller = substr($api, 0, $pos);
$action = substr($api, $pos + 1);
$reflection = new \ReflectionClass($controller);
$res = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach ($res as $method) {
if ($method->name == $action) {
$annotation = $method->getDocComment();
if (strpos($annotation, '@doc') !== false) {
$result[$version][$model] = array();
//$result[$version][$model]['all'] = $annotation;
//描述
preg_match('/@desc([^\\n]+)/', $annotation, $desc);
$result[$version][$model]['desc'] = isset($desc[1]) ? $desc[1] : '';
//参数
preg_match_all('/@param([^\\n]+)/', $annotation, $params);
foreach ($params[1] as $key => $val) {
$tmp = explode(' ', preg_replace('/\\s(\\s+)/', ' ', trim($val)));
isset($tmp[3]) || ($tmp[3] = 'N');
$tmp[1] = substr($tmp[1], 1);
$result[$version][$model]['params'][] = $tmp;
}
//请求示例
preg_match('/@req(.+?)(\\*\\s*?@|\\*\\/)/s', $annotation, $reqEg);
$result[$version][$model]['req'] = isset($reqEg[1]) ? $reqEg[1] : '';
//请求成功示例
preg_match('/@success(.+?)(\\*\\s*?@|\\*\\/)/s', $annotation, $success);
$result[$version][$model]['success'] = isset($success[1]) ? $success[1] : '';
//请求失败示例
preg_match('/@error(.+?)(\\*\\s*?@|\\*\\/)/s', $annotation, $error);
$result[$version][$model]['error'] = isset($error[1]) ? $error[1] : '';
}
}
}
}
}
$systemCode = (require __DIR__ . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR . 'code.php');
require __DIR__ . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR . 'doc.html';
}