當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Configurator::stripComments方法代碼示例

本文整理匯總了PHP中Configurator::stripComments方法的典型用法代碼示例。如果您正苦於以下問題:PHP Configurator::stripComments方法的具體用法?PHP Configurator::stripComments怎麽用?PHP Configurator::stripComments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Configurator的用法示例。


在下文中一共展示了Configurator::stripComments方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: ErrorController

require_once APPPATH . "auth/Auth.php";
require_once APPPATH . "auth/BasicAuth.php";
$c = new ErrorController();
// Keep cores as the last item
$config_files = array("general", "routes", "db", "cores", "auth");
$config_validator = new Validator();
// Check if all config files are present and validate them
foreach ($config_files as $file) {
    $filename = APPPATH . "config/" . $file . ".json";
    $schema = APPPATH . "config/schema/" . $file . "-schema.json";
    if (!file_exists($filename)) {
        echo "The file {$file} doesn't exist. Please check whether you have copied " . APPPATH . "config/{$file}.example.json to " . $filename;
        exit;
    } elseif (file_exists($schema)) {
        // Validate config file if schema exists
        $config_validator->check(json_decode(Configurator::stripComments(file_get_contents($filename))), json_decode(file_get_contents($schema)));
        if (!$config_validator->isValid()) {
            echo "JSON ({$file}.json) does not validate. Violations:\n";
            foreach ($config_validator->getErrors() as $error) {
                echo sprintf("[%s] %s\n", $error['property'], $error['message']);
            }
            exit;
        }
    }
}
// Start loading config files
try {
    $config = Configurator::load($config_files);
} catch (Exception $e) {
    // TODO: show nice error page
    echo $e->getMessage();
開發者ID:tdt,項目名稱:start,代碼行數:31,代碼來源:bootstrap.php

示例2: json_decode

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\FormError;
use Symfony\Component\Validator\Constraints as Assert;
// Allows to strip the comments from a json file
require_once STARTPATH . 'app/core/configurator.php';
// Used to write json to file, formatted to be read by humans
require_once __DIR__ . '/../src/nicejson-php/nicejson.php';
// Load users from file
// Fetch users from the auth.json file
$filename = STARTPATH . "app/config/auth.json";
// This object will be used by user management and route management, so don't delete it
$userObject = json_decode(file_get_contents($filename));
$users = get_object_vars($userObject);
// Fetch routes from file
$routeFile = STARTPATH . "app/config/cores.json";
$routeObject = json_decode(Configurator::stripComments(file_get_contents($routeFile)));
$routes = get_object_vars($routeObject);
// Save the routes used per user
$userroutes = array();
foreach ($routes as $namespace => $core) {
    foreach ($core->routes as $index => $route) {
        foreach ($route->users as $user) {
            $numberofroutes = 0;
            if (isset($userroutes[$user]->routes)) {
                $numberofroutes = count($userroutes[$user]->routes);
            }
            $userroutes[$user]->routes[$numberofroutes]->namespace = $namespace;
            $userroutes[$user]->routes[$numberofroutes]->index = $index;
        }
    }
}
開發者ID:tdt,項目名稱:ui,代碼行數:31,代碼來源:usermanagement.php


注:本文中的Configurator::stripComments方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。