Does anyone know of a good YAML Parser for PHP? If so, what are the pros and cons of this library?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Correctly parse PDF paragraphs with Python
- Can php detect if javascript is on or not?
I'd suggest the process followed in this article http://devzone.zend.com/article/2585-using-yaml-with-php-and-pecl
Try sfYaml, it is the best I know.
Symfony and Doctrine ORM are using this one.
To get it, you may Download Doctrine 1.2 and extract
sfYaml
fromvendor
directory.Let us know if it suits your needs.
If you need to test your YAML quickly, I built: http://yaml-online-parser.appspot.com/ . It helps me write YAML, especially while just learning.
Symfony2 has a YAML component which supports most of the YAML 1.2 spec
https://github.com/symfony/Yaml
If you're using a lot of YAML in your project you may find that the pure PHP libraries like spyc or Symfony YAML are not fast enough. There are at least two PHP bindings for C YAML parsers:
Spyc: https://github.com/mustangostang/spyc
Pure PHP implementation, so you don't need to make any modifications to the server for installation. If speed is of dire concern, it might not be the ideal solution, but if you're using YAML for configurations or relatively low-volume use, it is a fantastic solution.
Given a YAML document, Spyc will return an array that you can use however you see fit.
Given an array, Spyc will return a string which contains a YAML document built from your data.