本文整理汇总了PHP中static::path方法的典型用法代码示例。如果您正苦于以下问题:PHP static::path方法的具体用法?PHP static::path怎么用?PHP static::path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: path
/**
* Returns the path to the library
* @return string
*/
public static function path()
{
if (static::$path === null) {
static::$path = __DIR__ . DIRECTORY_SEPARATOR;
}
return static::$path;
}
示例2: usePath
/**
* Set the root path to use in the path methods.
*
* @param int|string $path Either one of the PATH class constants or an actual path to a directory that exists, and is readable
*
* @return void
*/
public static function usePath($path)
{
# Use the document root normally set via apache
if ($path === self::PATH_DOCUMENT_ROOT) {
if (empty($_SERVER["DOCUMENT_ROOT"]) || !is_dir($_SERVER["DOCUMENT_ROOT"])) {
throw new \InvalidArgumentException("DOCUMENT_ROOT not defined");
}
static::$path = $_SERVER["DOCUMENT_ROOT"];
return;
}
# Get the full path of the running script and use it's directory
if ($path === self::PATH_PHP_SELF) {
if (empty($_SERVER["PHP_SELF"]) || !($path = realpath($_SERVER["PHP_SELF"]))) {
throw new \InvalidArgumentException("PHP_SELF not defined");
}
static::$path = pathinfo($path, PATHINFO_DIRNAME);
return;
}
# Calculate the parent of the vendor directory and use that
if ($path === self::PATH_VENDOR_PARENT) {
static::$path = realpath(__DIR__ . "/../../../..");
return;
}
if (is_dir($path)) {
static::$path = $path;
} else {
throw new \InvalidArgumentException("Invalid path specified");
}
}
示例3: path
public static function path($path = '')
{
if (empty($path)) {
return static::$path;
}
static::$path = $path;
}
示例4: path
public static function path($path = null)
{
if (!empty($path)) {
static::$path = $path;
}
return static::$path;
}
示例5: _verify_directory_paths
/**
* Verify that the specified directory paths exist and
* attempts to create them if not.
* @throws \Exception
*/
private static function _verify_directory_paths()
{
// Clean strings.
static::$path = trim(static::$path);
static::$cache_path = trim(static::$cache_path);
// Verify that the path is not empty.
if (static::$path == '') {
throw new \Exception('No view path specified...');
}
// Verify that the cache path is not empty.
if (static::$cache_path == '') {
throw new \Exception('No cache path specified...');
}
if (!is_dir(static::$base_path . static::$path)) {
// Attempt to create directory.
mkdir(static::$base_path . static::$path);
if (!is_dir(static::$base_path . static::$path)) {
throw new \Exception('"' . static::$base_path . static::$path . '" does not exist."');
}
}
if (!is_dir(static::$base_path . static::$cache_path)) {
// Attempt to create directory.
mkdir(static::$base_path . static::$cache_path);
if (!is_dir(static::$base_path . static::$cache_path)) {
throw new \Exception('"' . static::$base_path . static::$cache_path . '" does not exist."');
}
}
}
示例6: route
public static function route($routepath = null, $root = null)
{
// Calculate root (parameter -> global const -> guessed)
static::$root = $root ?: ROOT ?: dirname($_SERVER['DOCUMENT_ROOT']);
if (substr(static::$root, -1) != DIRECTORY_SEPARATOR) {
static::$root .= DIRECTORY_SEPARATOR;
}
// Get path to route
static::$path = $routepath ?: $_REQUEST['routepath'];
static::$path = str_replace(chr(0), '', static::$path);
// Protect against poison null byte attacks
// Split the url on '/'
static::$parts = array_filter(explode('/', static::$path));
if (!static::$parts[0]) {
static::$parts[0] = static::$default;
}
// If first part is empty, replace with default
// Keep popping file path tokens from static::$parts until we find a routable target, or run out of parts
while (count(static::$parts)) {
// Build filename
foreach (static::$route_prefix as $pre) {
$path = static::$root . $pre . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, static::$parts);
// If file exists, then include controller and return.
if (file_exists($path . static::$extension)) {
return static::$filename = $path . static::$extension;
}
}
// Pop the next token off the path, and prepend it to the list of unrouteable parts
array_unshift(static::$unrouted_parts, array_pop(static::$parts));
}
// Could not find a page to route to - throw exception
throw new HTTP\NotFound();
}
示例7: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*/
protected function setUp()
{
static::$path = realpath(__DIR__ . '/Tmpl/plates');
if (!static::$path) {
throw new \RuntimeException('Path not exists');
}
$this->instance = new PlatesRenderer(static::$path);
}
示例8: __construct
public function __construct(Request $request)
{
static::$path = $request->path();
foreach (static::$paths as $k => $v) {
if (strpos(static::$path, $k) !== false) {
return $this->table = $v;
}
}
}
示例9: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*/
protected function setUp()
{
static::$path = realpath(__DIR__ . '/Tmpl/blade');
if (!static::$path) {
throw new \RuntimeException('Path not exists');
}
Folder::create(__DIR__ . '/cache');
$this->instance = new BladeRenderer(static::$path, array('cache_path' => __DIR__ . '/cache'));
}
示例10: generate
/**
* Method for generating Main configuration file
*
* @param array $filesList
* @param int $poller_id
* @param string $path
* @param string $filename
* @param int $testing
*/
public static function generate(&$filesList, $poller_id, $path, $filename, $testing = 0)
{
static::$path = rtrim($path, '/');
/* Get Content */
$content = static::getContent($poller_id, $filesList, $testing);
/* Write Check-Command configuration file */
WriteConfigFile::writeParamsFile($content, $path . $poller_id . "/" . $filename, $filesList, $user = "API");
unset($content);
}
示例11: __construct
/**
* WPLogger constructor.
* インスタンスの初期化
*/
private function __construct()
{
static::$path = get_template_directory() . '/logs/debug.log';
static::$logger = new Logger('wptheme');
$output = "[%datetime%] %level_name%: %message% %context% %extra%\n";
$formatter = new LineFormatter($output);
$stream = new StreamHandler(static::$path, Logger::DEBUG);
$stream->setFormatter($formatter);
static::$logger->pushHandler($stream);
}
示例12: path
public static function path($filename = '')
{
if (static::$path === null) {
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http';
$server = $_SERVER['SERVER_NAME'];
$directory = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');
static::$path = sprintf("%s://%s%s/", $protocol, $server, $directory);
}
return static::$path . $filename;
}
示例13: __construct
public function __construct($identifier, $config)
{
$this->config = isset($config['file']) ? $config['file'] : array();
// check for an expiration override
$this->expiration = $this->_validate_config('expiration', isset($this->config['expiration']) ? $this->config['expiration'] : $this->expiration);
// determine the file cache path
static::$path = !empty($this->config['path']) ? $this->config['path'] : APPPATH . 'cache' . DS;
if (!is_dir(static::$path) || !is_writable(static::$path)) {
throw new \Cache_Exception('Cache directory does not exist or is not writable.');
}
parent::__construct($identifier, $config);
}
示例14: init
public static function init()
{
static::$path = J_APPPATH . "storage" . DS . "cache" . DS;
if (Request::isLocal()) {
if (!File::exists(static::$path)) {
trigger_error("Directory <b>" . static::$path . "</b> doesn't exists.");
} else {
if (!is_writable(static::$path)) {
trigger_error("Directory <b>" . static::$path . "</b> is not writable.");
}
}
}
}
示例15: _init
/**
* static init
*
* @return void
*/
public static function _init()
{
if (!($path = CCConfig::create("Packtacular::packtacular")->path)) {
throw new CCException("CCPacktacular - please set your packtacular path!");
}
// is there a cache dir?
if (!is_dir(PUBLICPATH . $path)) {
if (!mkdir(PUBLICPATH . $path, 0755, true)) {
throw new CCException("CCPacktacular - could not create Packtacular folder at: {$path}");
}
}
static::$path = '/' . $path;
}