PHP YAML Parsers [closed]

2019-01-08 05:02发布

Does anyone know of a good YAML Parser for PHP? If so, what are the pros and cons of this library?

标签: php parsing yaml
8条回答
看我几分像从前
2楼-- · 2019-01-08 05:37

Last updated: July 26th, 2017

Here's a summary of the state of YAML in PHP:

  • Wrappers to C libraries: You'll probably want these if you need sheer speed:
    • php-yaml: Wrapper for LibYAML. Available as a PECL extension; it is also the one on PHP's docs.
    • syck: Binding to syck; also available as a PECL extension. (dated, see below)

  • Pure PHP implementations:

    • sfYaml: Symfony's YAML component. You can see its authors' motivations here. He wanted something that was "easy to use, fast, unit tested and had clear error messages."
    • spyc: YAML parser without dependencies

At the time of this writing, the latest versions release dates for the aforementioned libraries and the versions of the YAML spec (1.2 is the latest version) they support are:

php-yaml   1.3.0     2016-09-24     YAML 1.1  [PHP 5]
php-yaml   2.0.0     2016-09-24     YAML 1.1  [PHP 7]
syck       0.9.3     2008-11-18     YAML 1.0
sfYaml     3.3.5     2017-06-15     YAML 1.1, most of 1.2
spyc       0.6.2     2017-02-24     YAML 1.1 
查看更多
We Are One
3楼-- · 2019-01-08 05:49

The symfony framework makes very heavy use of YAML, this blog post by Grégoire Hubert demonstrates using their YAML library in a non-symfony project.

查看更多
登录 后发表回答