当前位置: 首页>>代码示例>>PHP>>正文


PHP YAML::decode_file方法代码示例

本文整理汇总了PHP中YAML::decode_file方法的典型用法代码示例。如果您正苦于以下问题:PHP YAML::decode_file方法的具体用法?PHP YAML::decode_file怎么用?PHP YAML::decode_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在YAML的用法示例。


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

示例1: __construct

 public function __construct($config)
 {
     $this->config = $config;
     $dir = dirname(__FILE__);
     if (file_exists($dir . '/repos.yml')) {
         $this->repos = YAML::decode_file($dir . '/repos.yml');
         if ($this->verify_repos() && file_exists($dir . '/flat.yml')) {
             $this->flat = YAML::decode_file($dir . '/flat.yml');
         } else {
             $this->flat = $this->flatten($this->repos);
         }
     } else {
         $this->rebuild();
     }
     //write file back out
     file_put_contents($dir . '/repos.yml', YAML::encode($this->repos));
     file_put_contents($dir . '/flat.yml', YAML::encode($this->flat));
 }
开发者ID:jonlb,项目名称:jxLoader,代码行数:18,代码来源:loader.class.php

示例2: parse_manifest

 private function parse_manifest($package_path)
 {
     $package_path = preg_replace('/\\/$/', '', $package_path) . '/';
     $manifest = YAML::decode_file($package_path . 'package.yml');
     if (empty($manifest)) {
         throw new Exception("package.yml not found in {$package_path}, or unable to parse manifest.");
     }
     $package_name = $manifest['name'];
     if ($this->root == null) {
         $this->root = $package_name;
     }
     if (array_has($this->manifests, $package_name)) {
         return;
     }
     $manifest['path'] = $package_path;
     $this->manifests[$package_name] = $manifest;
     foreach ($manifest['sources'] as $i => $path) {
         $path = $package_path . $path;
         // this is where we "hook" for possible other replacers.
         $source = $this->replace_build($package_path, file_get_contents($path));
         $descriptor = array();
         // get contents of first comment
         preg_match('/^\\s*\\/\\*\\s*(.*?)\\s*\\*\\//s', $source, $matches);
         if (!empty($matches)) {
             // get contents of YAML front matter
             preg_match('/^-{3}\\s*$(.*?)^(?:-{3}|\\.{3})\\s*$/ms', $matches[1], $matches);
             if (!empty($matches)) {
                 $descriptor = YAML::decode($matches[1]);
             }
         }
         // populate / convert to array requires and provides
         $requires = (array) (!empty($descriptor['requires']) ? $descriptor['requires'] : array());
         $provides = (array) (!empty($descriptor['provides']) ? $descriptor['provides'] : array());
         $file_name = !empty($descriptor['name']) ? $descriptor['name'] : basename($path, '.js');
         // "normalization" for requires. Fills up the default package name from requires, if not present.
         foreach ($requires as $i => $require) {
             $requires[$i] = implode('/', $this->parse_name($package_name, $require));
         }
         $license = array_get($descriptor, 'license');
         $this->packages[$package_name][$file_name] = array_merge($descriptor, array('package' => $package_name, 'requires' => $requires, 'provides' => $provides, 'source' => $source, 'path' => $path, 'package/name' => $package_name . '/' . $file_name, 'license' => empty($license) ? array_get($manifest, 'license') : $license));
     }
 }
开发者ID:pizarrodiego,项目名称:packager,代码行数:42,代码来源:packager.php

示例3: __construct

 public function __construct($manifest_path)
 {
     $this->package_path = dirname($manifest_path) . '/';
     $this->manifest = YAML::decode_file($manifest_path);
     $this->files = array();
     foreach ($this->manifest['sources'] as $i => $path) {
         $path = $this->package_path . $path;
         $file = file_get_contents($path);
         // yaml header
         preg_match("/\\/\\*\\s*[-]{3}(.*)[.]{3}\\s*\\*\\//s", $file, $matches);
         // this is a crappy regexp :)
         // hack to support unindented lists. hell might break loose. -- Taken from http://github.com/Guille/PluginsKit by Guillermo Rauch
         $rawYAML = preg_replace('/$([\\s]+)-/m', '$1 -', trim($matches[1]));
         $descriptor = YAML::decode($rawYAML);
         // populate / convert to array requires and provides
         if (!empty($descriptor['requires'])) {
             if (!is_array($descriptor['requires'])) {
                 $descriptor['requires'] = array($descriptor['requires']);
             }
         } else {
             $descriptor['requires'] = array();
         }
         if (!empty($descriptor['provides'])) {
             if (!is_array($descriptor['provides'])) {
                 $descriptor['provides'] = array($descriptor['provides']);
             }
         } else {
             $descriptor['provides'] = array();
         }
         if (!array_key_exists('name', $descriptor)) {
             $descriptor['name'] = basename($path, '.js');
         }
         // Strip out beginning "/" to support `requires: [/Foo, /Bar]`
         foreach ($descriptor['requires'] as $key => $require) {
             $descriptor['requires'][$key] = preg_replace('/^\\//', '', $require);
         }
         $this->files[$descriptor['name']] = array('description' => $descriptor['description'], 'requires' => $descriptor['requires'], 'provides' => $descriptor['provides'], 'source' => $file, 'path' => $path);
     }
 }
开发者ID:subtleGradient,项目名称:packager,代码行数:39,代码来源:packager.php

示例4: parse_manifest

 private function parse_manifest($path)
 {
     $pathinfo = pathinfo($path);
     if (is_dir($path)) {
         $package_path = $pathinfo['dirname'] . '/' . $pathinfo['basename'] . '/';
         if (file_exists($package_path . 'package.yml')) {
             $manifest_path = $package_path . 'package.yml';
             $manifest_format = 'yaml';
         } else {
             if (file_exists($package_path . 'package.yaml')) {
                 $manifest_path = $package_path . 'package.yaml';
                 $manifest_format = 'yaml';
             } else {
                 if (file_exists($package_path . 'package.json')) {
                     $manifest_path = $package_path . 'package.json';
                     $manifest_format = 'json';
                 }
             }
         }
     } else {
         if (file_exists($path)) {
             $package_path = $pathinfo['dirname'] . '/';
             $manifest_path = $package_path . $pathinfo['basename'];
             $manifest_format = $pathinfo['extension'];
         }
     }
     if ($manifest_format == 'json') {
         $manifest = json_decode(file_get_contents($manifest_path), true);
     } else {
         if ($manifest_format == 'yaml' || $manifest_format == 'yml') {
             $manifest = YAML::decode_file($manifest_path);
         }
     }
     if (empty($manifest)) {
         throw new Exception("manifest not found in {$package_path}, or unable to parse manifest.");
     }
     $package_name = $manifest['name'];
     if ($this->root == null) {
         $this->root = $package_name;
     }
     if (array_has($this->manifests, $package_name)) {
         return;
     }
     $manifest['path'] = $package_path;
     $manifest['manifest'] = $manifest_path;
     $this->manifests[$package_name] = $manifest;
     foreach ($manifest['sources'] as $i => $path) {
         $path = $package_path . $path;
         // this is where we "hook" for possible other replacers.
         $source = file_get_contents($path);
         $descriptor = array();
         // get contents of first comment
         preg_match('/\\/\\*\\s*^---(.*?)^\\.\\.\\.\\s*\\*\\//ms', $source, $matches);
         if (!empty($matches)) {
             $descriptor = YAML::decode($matches[0]);
         }
         // populate / convert to array requires and provides
         $requires = (array) (!empty($descriptor['requires']) ? $descriptor['requires'] : array());
         $provides = (array) (!empty($descriptor['provides']) ? $descriptor['provides'] : array());
         $file_name = !empty($descriptor['name']) ? $descriptor['name'] : basename($path, '.js');
         // "normalization" for requires. Fills up the default package name from requires, if not present.
         foreach ($requires as $i => $require) {
             $requires[$i] = implode('/', $this->parse_name($package_name, $require));
         }
         $license = array_get($descriptor, 'license');
         $this->packages[$package_name][$file_name] = array_merge($descriptor, array('package' => $package_name, 'requires' => $requires, 'provides' => $provides, 'source' => $source, 'path' => $path, 'package/name' => $package_name . '/' . $file_name, 'license' => empty($license) ? array_get($manifest, 'license') : $license));
     }
 }
开发者ID:joeke,项目名称:modx-minify,代码行数:68,代码来源:packager.php

示例5: putenv

<?php

putenv('LC_ALL=en_US.UTF-8');
setlocale(LC_ALL, null);
require "libs/packager/packager.php";
require "libs/control/control.php";
require "libs/markdown.php";
$packages = YAML::decode_file('packages.yml');
if (empty($packages)) {
    $packages = array();
}
$config = YAML::decode_file('config.yml');
if (empty($config['view']['theme'])) {
    $config['view']['theme'] = 'packager';
}
Control::config('default_controller', 'web');
new Control();
开发者ID:kamicane,项目名称:packager-web,代码行数:17,代码来源:index.php

示例6: die

<?php

// connect database
$db_conf = YAML::decode_file('config/database.yml');
$mysql = mysql_connect($db_conf[ENV]['host'] . ':' . $db_conf[ENV]['port'], $db_conf[ENV]['user'], $db_conf[ENV]['pass']) or die('Could not connect: ' . mysql_error());
mysql_select_db($db_conf[ENV]['database']) or die('Could not select database');
开发者ID:phaedryx,项目名称:wannabe-mvc,代码行数:6,代码来源:connect_db.php

示例7: __construct

 function __construct($params = array())
 {
     $this->properties = YAML::decode_file("db/schemas/{$this->table}.yml");
     $this->set_properties($params);
 }
开发者ID:phaedryx,项目名称:wannabe-mvc,代码行数:5,代码来源:model_base.php


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