These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

Parsing YAML in PHP

Author
ZigZag Joe
Di-Tron Heavy Industries
OnlyFleets.
#1 - 2012-06-20 16:15:09 UTC  |  Edited by: ZigZag Joe
... if you are on a shared host, or windows, god help you.

Over the course of working NotificationTexts into plain english, I got to figure out exactly where YAML parsing in php is at. PHP has two native extensions, however the problem arises in that I'm on a shared host and thus cannot install these extensions that aren't installed by default. So, I got to look into... alternative methods.

Found 3 native php implementations; each claiming to be better than the other guy for various reasons. Also tested a hack and two PECL versions.

spyc - http://code.google.com/p/spyc/
symfony/Yaml - https://github.com/symfony/Yaml
horde-yaml - http://pear.horde.org/

3 implementations, surely one will work, right? Right?

As it turns out, no. All of them could parse standard key: value (newline) YAML, but choked on more advanced features.

spyc could not deal with multiline strings (even if quoted), and it didn't parse arrays correctly. It was the fastest of the native php ones, though.

symfony/YAML required contortions to even get it to work, and it threw exceptions on 2 (of 3) more advanced cases. It did manage to parse arrays, but eating **** and dying otherwise makes it a non starter.

horde-yaml needed modifications to work, as well as including all the files comprising it yourself. It repeated spyc's performance of bad array and multiline string parsing.

In a fit of desperation, I ended up taking a functional YAML parser (PyYAML ported to JS) and writing a node.js script to parse the YAML and spit out JSON, which php then parsed. This works, but of course uses a crap ton of memory and time compared to other parsers (it's still <0.1sec). Failing a port of PyYAML or jsyaml, this is what I've got to use for the future. I might port jsyaml when really, really bored, but this works for now.

After the fact, I tested both php PECL extensions: yaml (using libyaml), and syck (using syck). Both parsed all cases correctly and very, very quickly. yaml was slightly quicker to parse, and it was easier to install as it and the library it uses are under active development.

Fun times.

Oh, and on the topic of notifications, if anyone knows what notification types 105-108 are for, please let me know. I can tell they are FW, and quite routine at that, but I have no idea what they actually /are/. I'll love you long time if you go to http://ridetheclown.com/eveapi/audit.php, view notifications, and compare ingame to figure out what their names are by finding a notification ingame with the same data.


Test data and so on is at http://ridetheclown.com/wp/2012/06/19/the-state-of-yaml-in-php/


EDIT: Turns out CCP forums can't deal with anything being inside of <>. Quality coding, that.

Original API Jackknife/Auditor developer. http://ridetheclown.com/eveapi/audit.php

Khorkrak
KarmaFleet
Goonswarm Federation
#2 - 2012-06-20 16:26:18 UTC
Just go to YAML Official Site Has links to parsers for most languages.

Developer of http://www.decloaked.com and http://sourceforge.net/projects/pykb/

ZigZag Joe
Di-Tron Heavy Industries
OnlyFleets.
#3 - 2012-06-20 16:35:46 UTC
Thank you for reading my post. Or, not - if you had, you would have seen that I was evaluating PHP parsers, not looking for one.

Original API Jackknife/Auditor developer. http://ridetheclown.com/eveapi/audit.php