• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP yaml_parse_file函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中yaml_parse_file函数的典型用法代码示例。如果您正苦于以下问题:PHP yaml_parse_file函数的具体用法?PHP yaml_parse_file怎么用?PHP yaml_parse_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了yaml_parse_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: load

 /**
  * Loads the specified configuration file and returns its content as an
  * array. If the file does not exist or could not be loaded, an empty
  * array is returned
  *
  * @param string $pathAndFilename Full path and filename of the file to load, excluding the file extension (ie. ".yaml")
  * @param boolean $allowSplitSource If TRUE, the type will be used as a prefix when looking for configuration files
  * @return array
  * @throws \TYPO3\Flow\Configuration\Exception\ParseErrorException
  */
 public function load($pathAndFilename, $allowSplitSource = false)
 {
     $pathsAndFileNames = array($pathAndFilename . '.yaml');
     if ($allowSplitSource === true) {
         $splitSourcePathsAndFileNames = glob($pathAndFilename . '.*.yaml');
         if ($splitSourcePathsAndFileNames !== false) {
             sort($splitSourcePathsAndFileNames);
             $pathsAndFileNames = array_merge($pathsAndFileNames, $splitSourcePathsAndFileNames);
         }
     }
     $configuration = array();
     foreach ($pathsAndFileNames as $pathAndFilename) {
         if (is_file($pathAndFilename)) {
             try {
                 if ($this->usePhpYamlExtension) {
                     $loadedConfiguration = @yaml_parse_file($pathAndFilename);
                     if ($loadedConfiguration === false) {
                         throw new \TYPO3\Flow\Configuration\Exception\ParseErrorException('A parse error occurred while parsing file "' . $pathAndFilename . '".', 1391894094);
                     }
                 } else {
                     $loadedConfiguration = Yaml::parse($pathAndFilename);
                 }
                 if (is_array($loadedConfiguration)) {
                     $configuration = Arrays::arrayMergeRecursiveOverrule($configuration, $loadedConfiguration);
                 }
             } catch (\TYPO3\Flow\Error\Exception $exception) {
                 throw new \TYPO3\Flow\Configuration\Exception\ParseErrorException('A parse error occurred while parsing file "' . $pathAndFilename . '". Error message: ' . $exception->getMessage(), 1232014321);
             }
         }
     }
     return $configuration;
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:42,代码来源:YamlSource.php


示例2: offsetGet

 /**
  * Offset to retrieve
  */
 public function offsetGet($offset)
 {
     if (empty($this->configs[$offset])) {
         $this->configs = yaml_parse_file($this->path);
     }
     return $this->configs[$offset];
 }
开发者ID:fyibmsd,项目名称:laralite,代码行数:10,代码来源:Config.php


示例3: footerMenu

 public function footerMenu(FactoryInterface $factory, array $options)
 {
     $file = yaml_parse_file(__DIR__ . '/../../../../../../app/config/globals.yml');
     $em = $this->container->get('doctrine.orm.entity_manager');
     $menu = $factory->createItem('root');
     // $menu->addChild('Главная', array('route' => 'index'));
     $mainCategory = $em->getRepository('CMSBundle:Category')->find(2);
     foreach ($em->getRepository('CMSBundle:Page')->findBy(array('parent' => null, 'enabled' => 1, 'category' => $mainCategory)) as $page) {
         $menu->addChild($page->getTitle(), array('route' => 'page_show', 'routeParameters' => array('url' => $page->getUrl())));
     }
     // $faq = $em->createQueryBuilder('p')
     //     ->select('count(p)')
     //     ->from('CMSBundle:FAQ','p')
     //     ->where('1 = 1')
     //     ->getQuery()
     //     ->getResult();
     if ($file['twig']['globals']['footer']['faq']) {
         $menu->addChild('FAQ', array('route' => 'faq'));
     }
     if ($file['twig']['globals']['footer']['sitemap']) {
         $menu->addChild('Карта сайта', array('route' => 'sitemap'));
     }
     if ($file['twig']['globals']['footer']['reviews']) {
         $menu->addChild('Отзывы', array('route' => 'review'));
     }
     return $menu;
 }
开发者ID:sandello-alkr,项目名称:cmsbundle,代码行数:27,代码来源:Builder.php


示例4: slurp

 public static function slurp($path, $content = [])
 {
     foreach (scandir($path) as $file) {
         if (in_array($file, ['.', '..']) || $file[0] == '_') {
             continue;
         }
         if (is_dir($path . $file)) {
             $newpath = $path . $file . '/';
             $content[$file] = self::slurp($newpath, []);
             continue;
         }
         list($name, $ext) = explode('.', $file);
         if (in_array($ext, ['json', 'jsn'])) {
             $parsed = json_decode(file_get_contents($path . $file), true);
             if ($parsed == null) {
                 return trigger_error('Error parsing JSON : ' . $path . $file, E_USER_NOTICE);
             }
             $content[$name] = $parsed;
         }
         if (in_array($ext, ['yaml', 'yml'])) {
             $parsed = yaml_parse_file($path . $file);
             $content[$name] = $parsed;
         }
     }
     return $content;
 }
开发者ID:acidjazz,项目名称:larjectus,代码行数:26,代码来源:Objectus.php


示例5: indexAction

 /**
  * @Route("/admin/", name="admin_index")
  * @Template()
  */
 public function indexAction(Request $request)
 {
     $file = yaml_parse_file(__DIR__ . '/../../../../../../app/config/globals.yml');
     if ($request->getMethod() == 'POST') {
         // print_r ($request);
         foreach ($file['twig']['globals'] as $place => $vars) {
             foreach ($vars as $name => $val) {
                 if (count($val) > 1) {
                     foreach ($val as $name1 => $val1) {
                         if ($request->get($place . '_' . $name . '_' . $name1, false)) {
                             $file['twig']['globals'][$place][$name][$name1] = true;
                         } else {
                             $file['twig']['globals'][$place][$name][$name1] = false;
                         }
                     }
                 } else {
                     if ($request->get($place . '_' . $name, false)) {
                         $file['twig']['globals'][$place][$name] = true;
                     } else {
                         $file['twig']['globals'][$place][$name] = false;
                     }
                 }
             }
         }
         yaml_emit_file(__DIR__ . '/../../../../../app/config/globals.yml', $file);
     }
     // $form = $this->createForm(new BannerType(), $entity, array(
     //     'action' => $this->generateUrl('manager_banner_update', array('id' => $entity->getId())),
     //     'method' => 'PUT',
     // ));
     // $form->add('submit', 'submit', array('label' => 'Update'));
     $em = $this->getDoctrine()->getManager();
     $banners = $em->getRepository('CMSBundle:Banner')->findAll();
     return array('banners' => $banners, 'globals' => $file['twig']['globals']);
 }
开发者ID:sandello-alkr,项目名称:cmsbundle,代码行数:39,代码来源:AdminController.php


示例6: loadFile

 public static function loadFile($file)
 {
     if (function_exists('yaml_parse_file')) {
         // returns array() if no data, NULL if error.
         $a = yaml_parse_file($file);
         if ($a === NULL || $a === false) {
             throw new WFException("Error processing YAML file: {$file}");
         }
         return $a;
     } else {
         if (function_exists('syck_load')) {
             // php-lib-c version, much faster!
             // ******* NOTE: if using libsyck with PHP, you should install from pear/pecl (http://trac.symfony-project.com/wiki/InstallingSyck)
             // ******* NOTE: as it escalates YAML syntax errors to PHP Exceptions.
             // ******* NOTE: without this, if your YAML has a syntax error, you will be really confused when trying to debug it b/c syck_load will just return NULL.
             $yaml = NULL;
             $yamlfile = file_get_contents($file);
             if (strlen($yamlfile) != 0) {
                 $yaml = syck_load($yamlfile);
             }
             if ($yaml === NULL) {
                 $yaml = array();
             }
             return $yaml;
         } else {
             // php version
             return Horde_Yaml::loadFile($file);
         }
     }
 }
开发者ID:apinstein,项目名称:phocoa,代码行数:30,代码来源:WFYaml.php


示例7: run

 public function run()
 {
     if (file_exists(app_path() . '/config/creds.yml')) {
         $creds = yaml_parse_file(app_path() . '/config/creds.yml');
     } else {
         $creds = array('admin_email' => '[email protected]');
     }
     $admin = new Role();
     $admin->name = 'Admin';
     $admin->save();
     $independent_sponsor = new Role();
     $independent_sponsor->name = 'Independent Sponsor';
     $independent_sponsor->save();
     $permIds = array();
     foreach ($this->adminPermissions as $permClass => $data) {
         $perm = new Permission();
         foreach ($data as $key => $val) {
             $perm->{$key} = $val;
         }
         $perm->save();
         $permIds[] = $perm->id;
     }
     $admin->perms()->sync($permIds);
     $user = User::where('email', '=', $creds['admin_email'])->first();
     $user->attachRole($admin);
     $createDocPerm = new Permission();
     $createDocPerm->name = "independent_sponsor_create_doc";
     $createDocPerm->display_name = "Independent Sponsoring";
     $createDocPerm->save();
     $independent_sponsor->perms()->sync(array($createDocPerm->id));
 }
开发者ID:iaincollins,项目名称:madison,代码行数:31,代码来源:RbacSeeder.php


示例8: onEnable

 public function onEnable()
 {
     @mkdir($this->getDataFolder());
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     if (file_exists($this->getDataFolder() . "/chatblock.yml")) {
         $this->chatBlock = yaml_parse_file($this->getDataFolder() . "/chatblock.yml");
     } else {
         $this->chatBlock = array();
     }
     if (file_exists($this->getDataFolder() . "/commandcapture.yml")) {
         $this->commandCapture = yaml_parse_file($this->getDataFolder() . "/commandcapture.yml");
     } else {
         $this->commandCapture = array();
     }
     if (file_exists($this->getDataFolder() . "/denycommand.yml")) {
         $this->denyCommand = yaml_parse_file($this->getDataFolder() . "/denycommand.yml");
     } else {
         $this->denyCommand = array();
     }
     if (file_exists($this->getDataFolder() . "/movelock.yml")) {
         $this->moveLock = yaml_parse_file($this->getDataFolder() . "/movelock.yml");
     } else {
         $this->moveLock = array();
     }
     $commandMap = $this->getServer()->getCommandMap();
     $commandMap->register("remote", new xSudoCommand($this, "remote", "Allows you to run commands as console or someone else."));
     $commandMap->register("rcmd", new xSudoCommand($this, "rcmd", "Allows you to run commands as console or someone else."));
     $commandMap->register("pd", new PDCommand($this, "pd", "Think yourself how to use."));
     $commandMap->register("p", new PCommand($this, "p", "Think yourself how to use."));
     $commandMap->register("ml", new MLCommand($this, "ml", "Think yourself how to use."));
     $commandMap->register("cb", new CBCommand($this, "cb", "Think yourself how to use."));
     $commandMap->register("cc", new CCCommand($this, "cc", "Think yourself how to use."));
     $commandMap->register("dc", new DCCommand($this, "dc", "Think yourself how to use."));
 }
开发者ID:nao20010128nao,项目名称:PlayerPrivacy,代码行数:34,代码来源:xSudo.php


示例9: run

 public function run()
 {
     global $argc, $argv;
     $path = sprintf('%s/%s', dirname(__FILE__), $this->settingsFile);
     if (file_exists($path)) {
         $this->settings = yaml_parse_file($path);
     } else {
         printf('File %s does not exist', $path);
         exit;
     }
     $cmd = $argv[1];
     if ($cmd == 'project') {
     } elseif ($cmd == 'module') {
         $module = $argv[2];
         $moduleDir = sprintf('%s/modules/%s', $this->settings['root'], $module);
         $moduleTemplatesDir = sprintf('%s/modules/%s/templates', $this->settings['root'], $module);
         $moduleControllerFile = sprintf('%s/modules/%s/controller.php', $this->settings['root'], $module);
         $moduleRoutesFile = sprintf('%s/modules/%s/routes.yml', $this->settings['root'], $module);
         $moduleModelsFile = sprintf('%s/modules/%s/models.yml', $this->settings['root'], $module);
         $controlllerContent = "<?php\n\nclass [[module]] {\n\tpublic function index(){\n\t\techo 'index :)';\n\t}\n}";
         $controlllerContent = str_replace('[[module]]', ucfirst($module), $controlllerContent);
         $routesContent = "- route: ^\$\n  controller: index";
         $modelsContent = '';
         if (!file_exists($moduleDir)) {
             mkdir($moduleDir);
             mkdir($moduleTemplatesDir);
             file_put_contents($moduleControllerFile, $controlllerContent);
             file_put_contents($moduleRoutesFile, $routesContent);
             file_put_contents($moduleModelsFile, $modelsContent);
         } else {
             echo "Module directory already exists.\n";
         }
     }
     return 0;
 }
开发者ID:hcvcastro,项目名称:highlands-framework,代码行数:35,代码来源:manage.php


示例10: getSpecFile

 /**
  * Get spec array for current service
  *
  * @param $service string available api service (user|account|admin)
  * @return array
  */
 protected function getSpecFile($service)
 {
     $describer = new Describer(self::$apiVersion, $service, \Scalr::getContainer()->config());
     $reflectionSpecProperties = (new \ReflectionClass('Scalr\\Util\\Api\\Describer'))->getProperty('specFile');
     $reflectionSpecProperties->setAccessible(true);
     return yaml_parse_file($reflectionSpecProperties->getValue($describer));
 }
开发者ID:mheydt,项目名称:scalr,代码行数:13,代码来源:DeprecatedPathTest.php


示例11: loadConfig

 /**
  * Load config data. Support php|ini|yml config formats.
  *
  * @param string|\SplFileInfo $configFile
  * @throws ConfigException
  */
 public function loadConfig($configFile)
 {
     if (!$configFile instanceof \SplFileInfo) {
         if (!is_string($configFile)) {
             throw new ConfigException('Mismatch type of variable.');
         }
         $path = realpath($this->basePath . $configFile);
         // check basePath at mutation
         if (strpos($configFile, '..') || !strpos($path, realpath($this->basePath))) {
             throw new ConfigException('Config file name: ' . $configFile . ' isn\'t correct.');
         }
         if (!is_file($path) || !is_readable($path)) {
             throw new ConfigException('Config file: ' . $path . ' not found of file isn\'t readable.');
         }
         $configFile = new \SplFileInfo($path);
     }
     $path = $configFile->getRealPath();
     $ext = $configFile->getExtension();
     $key = $configFile->getBasename('.' . $ext);
     if ('php' === $ext) {
         $this->data[$key] = (include $path);
     } elseif ('ini' === $ext) {
         $this->data[$key] = parse_ini_file($path, true);
     } elseif ('yml' === $ext) {
         if (!function_exists('yaml_parse_file')) {
             throw new ConfigException("Function `yaml_parse_file` isn't supported.\n" . 'http://php.net/manual/en/yaml.requirements.php');
         }
         $this->data[$key] = yaml_parse_file($path);
     }
 }
开发者ID:qwant50,项目名称:config,代码行数:36,代码来源:Config.php


示例12: __construct

 public function __construct(string $path)
 {
     try {
         $this->config = yaml_parse_file($path);
     } catch (\Exception $e) {
         echo 'Plosky Config Exception: ' . $e->getMessage() . '\\n';
     }
 }
开发者ID:plosky,项目名称:plosky,代码行数:8,代码来源:Plosky.php


示例13: router

 protected function router()
 {
     static $router = null;
     if (is_null($router)) {
         $router = new \Router(yaml_parse_file('app/config/routes.yml'));
     }
     return $router;
 }
开发者ID:subak,项目名称:cms_app_web,代码行数:8,代码来源:Page.php


示例14: __construct

 /**
  * Charge un nouveau fichier de configuration
  *
  * @param string $yamlPath Chemin vers le fichier de configuration
  * @throws Exception si le yml est mal formaté
  */
 public function __construct($yamlPath)
 {
     $data = yaml_parse_file($yamlPath);
     if ($data === false) {
         throw new Exception('yml malformed');
     }
     $this->arrayConvert($this, $data);
 }
开发者ID:solire,项目名称:conf,代码行数:14,代码来源:YmlToConf.php


示例15: getPluginDescription

 /**
  * Gets the PluginDescription from a plugin.yml
  *
  * @param string $file
  * @return PluginDescription
  * @throws \Exception
  */
 public static function getPluginDescription($file)
 {
     $descriptionArray = yaml_parse_file($file);
     if ($descriptionArray === false) {
         throw new \Exception("Could not read input plugin.yml file");
     }
     return new PluginDescription($descriptionArray);
 }
开发者ID:sekjun9878,项目名称:makeplugin,代码行数:15,代码来源:MakePlugin.php


示例16: backup

 public function backup($backups_path)
 {
     $creds = yaml_parse_file(app_path() . '/config/creds.yml');
     $timestamp = date('c', strtotime('now'));
     $filename = $timestamp . '_bak.sql';
     exec('mysqldump ' . $creds['database'] . ' -u' . $creds['username'] . ' -p' . $creds['password'] . ' > ' . $backups_path . '/' . $filename);
     $this->info("Backup created.");
 }
开发者ID:iaincollins,项目名称:madison,代码行数:8,代码来源:DatabaseBackup.php


示例17: doc_metadata

 protected function doc_metadata($file_name)
 {
     $path = "{$file_name}.yml";
     if (file_exists($path)) {
         return yaml_parse_file("{$file_name}.yml");
     } else {
         return [];
     }
 }
开发者ID:subak,项目名称:cms_app_web,代码行数:9,代码来源:Content.php


示例18: getYmlFdo

 function getYmlFdo($ymlfn)
 {
     $di = \yaml_parse_file($ymlfn);
     $fda = new FatcaDataArray($di, false, "", 2014, $this->conMan);
     $fda->start();
     $a2o = new Array2Oecd($fda);
     $a2o->convert();
     return $a2o->fdo;
 }
开发者ID:shadiakiki1986,项目名称:fatca-ides-php,代码行数:9,代码来源:FatcaDataOecdTest.php


示例19: run

 public function run()
 {
     if (file_exists(app_path() . '/config/creds.yml')) {
         $creds = yaml_parse_file(app_path() . '/config/creds.yml');
     } else {
         $creds = array('admin_email' => '[email protected]', 'admin_fname' => 'First', 'admin_lname' => 'Last', 'admin_password' => 'password');
     }
     DB::table('users')->insert(array('email' => $creds['admin_email'], 'password' => Hash::make($creds['admin_password']), 'fname' => $creds['admin_fname'], 'lname' => $creds['admin_lname'], 'token' => ''));
 }
开发者ID:iaincollins,项目名称:madison,代码行数:9,代码来源:UsersTableSeeder.php


示例20: loadRoutes

 public function loadRoutes()
 {
     foreach ($this->files as $file) {
         array_push($this->yaml, yaml_parse_file('routes/' . $file));
         var_dump($this->yaml);
         echo '<br><br>';
     }
     return $this;
 }
开发者ID:swos-,项目名称:slim-api,代码行数:9,代码来源:index.php



注:本文中的yaml_parse_file函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP yarpp_get_option函数代码示例发布时间:2022-05-23
下一篇:
PHP yaml_parse函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap