本文整理汇总了PHP中Path::getRoot方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::getRoot方法的具体用法?PHP Path::getRoot怎么用?PHP Path::getRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path::getRoot方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($filename = 'global')
{
if (file_exists(Path::getRoot('app/config/') . $filename . '.config')) {
$this->filepath = Path::getRoot('app/config/') . $filename . '.config';
} else {
$this->filepath = Path::getRoot('core/config/') . $filename . '.config';
}
$this->load();
}
示例2: includeController
public static function includeController($className, $folder = '')
{
if (!class_exists($className, false)) {
if (file_exists(Path::getRoot('app/controllers/' . $folder . '/' . $className . '.php'))) {
require_once Path::getRoot('app/controllers/' . $folder . '/' . $className . '.php');
} else {
if (file_exists(Path::getRoot('core/controllers/' . $folder . '/' . $className . '.php'))) {
require_once Path::getRoot('core/controllers/' . $folder . '/' . $className . '.php');
} else {
throw new Exception('Controller not exist. Please create Controller or configure route! ');
}
}
}
}
示例3: run
function run()
{
// Получаем URI.
$uri = $this->uri;
if (strpos($uri, '?') !== FALSE) {
parse_str(substr($uri, strpos($uri, '?') + 1), $_GET);
$uri = substr($uri, 0, strpos($uri, '?'));
}
if ($uri == '') {
$uri = 'none';
}
$segments = explode('/', $uri);
$this->routes[] = array('rules' => include Path::getRoot('app/routes.php'));
$uri = implode('/', $segments);
$this->routes = array_reverse($this->routes);
// Пытаемся применить к нему правила из конфигуации.
foreach ($this->routes as $routes) {
foreach ($routes['rules'] as $pattern => $route) {
// Если правило совпало.
if (preg_match("~^{$pattern}\$~", $uri) && $pattern != ' ') {
$internalRoute = preg_replace("~{$pattern}~", $route, $uri, 1);
// print_r($internalRoute);
// echo $uri;
// echo $route;
$segments = explode('|', $internalRoute);
$controller_folder = array_shift($segments);
$controller_url = array_shift($segments);
$controller = ucfirst($controller_url) . 'Controller';
$action_array = explode('-', array_shift($segments));
$action_name = '';
foreach ($action_array as $action) {
$action_name .= $action;
}
// echo $action_name;
$params = array();
$params['action'] = $action_name;
$action_name = ucfirst($action_name);
// echo $actionName;
if (!$action_name) {
$action_name = 'Index';
}
$action = 'action' . $action_name;
// Остальные сегменты — параметры.
$parameters = $segments;
// echo 12;
// print_r($parameters);
foreach ($parameters as &$parameter) {
$key_value = explode('=', $parameter);
if (isset($key_value[1])) {
$params[$key_value[0]] = $key_value[1];
} else {
$params[] = $key_value[0];
}
}
$params['controller'] = $controller_url;
$controller_object = ControllerFactory::getController($controller, $controller_folder);
self::$params = $params;
self::$rule = $pattern;
$controller_object->run($action, $params, $controller_url);
// Вызываем действие контроллера с параметрами
return;
}
}
}
$controller_folder = '';
//array_shift($segments);
$controller_url = array_shift($segments);
// two is controller
$controller = ucfirst($controller_url) . 'Controller';
// three — действие.
$action_array = explode('-', array_shift($segments));
$action_name = '';
foreach ($action_array as $action) {
$action_name .= $action;
}
$params = array();
$params['action'] = $action_name;
$action_name = ucfirst($action_name);
// echo $actionName;
if (!$action_name) {
$action_name = 'Index';
}
$action = 'action' . $action_name;
$parameters = $segments;
// $params = array();
foreach ($parameters as &$parameter) {
$key_value = explode('=', $parameter);
if (isset($key_value[1])) {
$params[$key_value[0]] = $key_value[1];
} else {
$params[] = $key_value[0];
}
}
$params['controller'] = $controller_url;
// Подключаем файл контроллера, если он имеется
//print_r($action);
// echo $controller_folder;
$controller_object = ControllerFactory::getController($controller, $controller_folder);
self::$params = $params;
// Если не загружен нужный класс контроллера или в нём нет
//.........这里部分代码省略.........
示例4: log
public static function log($message)
{
@file_put_contents(Path::getRoot('app/logs/log.txt'), date('Y-m-d h:i:s') . ' ' . $message . PHP_EOL, FILE_APPEND);
}
示例5: str_replace
<?php
use guidaMedia\Leroy\LeCore\LeSystemFunctions;
include '../../../bootStrap.php';
$fileName = str_replace('|', '/', $_GET['file']);
$filePath = Path::getRoot() . 'Skins/' . $_GET['accountId'] . '/Images/' . $fileName;
$file = null;
if ('.png' == substr($fileName, -4)) {
$file = imageCreateFromPng($filePath);
header("Content-type: image/png");
imagePng($file);
} elseif ('.gif' == substr($fileName, -4)) {
$file = imagecreatefromgif($filePath);
header("Content-type: image/gif");
imagegif($file);
} elseif (in_array(substr($fileName, -4), ['.jpg', 'jpeg'])) {
$file = imagecreatefromjpeg($filePath);
header("Content-type: image/jpeg");
imagejpeg($file);
}
if (!is_null($file)) {
imagedestroy($file);
}