Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/steevanb/php-yaml
Add some features to symfony/yaml
https://github.com/steevanb/php-yaml
php symfony
Last synced: 22 days ago
JSON representation
Add some features to symfony/yaml
- Host: GitHub
- URL: https://github.com/steevanb/php-yaml
- Owner: steevanb
- Created: 2017-03-18T20:27:03.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-13T17:58:06.000Z (almost 7 years ago)
- Last Synced: 2024-07-08T20:55:38.930Z (4 months ago)
- Topics: php, symfony
- Language: PHP
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
Awesome Lists containing this project
README
[![version](https://img.shields.io/badge/version-1.0.2-green.svg)](https://github.com/steevanb/php-yaml/tree/1.0.2)
[![symfony](https://img.shields.io/badge/symfony/yaml-^3.1-blue.svg)](https://github.com/symfony/yaml)
![Lines](https://img.shields.io/badge/code%20lines-214-green.svg)
![Total Downloads](https://poser.pugx.org/steevanb/php-yaml/downloads)
[![SensionLabsInsight](https://img.shields.io/badge/SensionLabsInsight-platinum-brightgreen.svg)](https://insight.sensiolabs.com/projects/00a42deb-03af-40da-a61f-b8abdd3a90b3/analyses/9)
[![Scrutinizer](https://scrutinizer-ci.com/g/steevanb/php-yaml/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/steevanb/php-yaml/)php-yaml
========Add features to [symfony/yaml](https://github.com/symfony/yaml).
As _steevanb\PhpYaml\Parser_ extends _Symfony\Component\Yaml\Parser_,
you have all Symfony YAML parser features.[Changelog](changelog.md)
Installation
------------Use _composer require_ :
```bash
composer require steevanb/php-yaml ^1.0
```Or add it manually to _composer.json_ :
```yaml
{
"require": {
"steevanb/php-yaml": "^1.0"
}
}
```How to use
----------Instead of calling _Symfony\Component\Yaml\Yaml::parse($content)_, you have to do this :
```php
use steevanb\PhpYaml\Parser;
$parser = new Parser();
$parser->parse(file_get_contents('foo.yml'));
```Function support
----------------You can call registered functions in yaml value :
````yaml
foo:
call_file_get_contents:
call_new_DateTime:
call_new_DateTime2:
````
By default, no function is registered into Parser. You need to manually register every function you need.You can register __ function. _$path_ is _$fileName_ path prefix :
```php
steevanb\PhpYaml\Parser::registerFileFunction($path = null);
```You can register __ function :
```php
steevanb\PhpYaml\Parser::registerDateFunction();
```You can register your own function :
```php
steevanb\PhpYaml\Parser::registerFunction('foo', function($bar, $baz) {
return $bar + $baz;
});
```
And call it in yaml :
```yaml
foo:
bar:
```