| PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >> |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|
#1 (permalink) |
|
Surpass Fan
On a golden path...
Joined in Nov 2004
Lives in San Francisco
364 posts
Gave thanks: 0
Thanked 3 times
|
Fun with YAML (it ain't markup language)
YAML (sounds like 'camel') is a human friendly data serialization language with a recursive name of YAML Ain't Markup Language. It can be used to write arrays and other fun data types in plain text (Unicode), and can be understood by a number of these dynamic languages we've got floating around. Perl, Python, PHP, Ruby, etc. See www.yaml.org for more info.
Here's an example of a nice, human friendly YAML document. Code:
--- name: Admiral ozmm age: 20 residency: San Francisco loves: - PHP - Ruby - Playing Guitar hates: [Gas Masks, Zombies] PHP Code:
If you're into the whole PHP thing, there is a pure PHP loader/dumper for YAML, called Spyc [spice] (a simple php yaml class). The project page is http://sourceforge.net/projects/spyc/. It's a newborn, so handle with care. If you want to lend a hand, it would be most appreciated. See Spyc in action under the demo section of http://ozmm.org/spyc/ A super-fast extension written in C for PHP (and other languages) is Syck. You can get it at www.whytheluckystiff.net/syck/. If you are using Ruby, you already have Syck (YAML support is built into Ruby's standard library). |
|
|
|
|
|
#2 (permalink) |
|
L'Awesome Advocate
Super #1
Joined in May 2004
Lives in .au
Hosted on Mango
2,423 posts
Gave thanks: 1
Thanked 5 times
|
Wow, that looks like it can save a lot of time and help out some n00bs like me.
__________________
When I get sad, I stop being sad, and be AWESOME instead. True story.
|
|
|
|
|
|
#3 (permalink) |
|
is scientific.
Resident.
Joined in Mar 2004
Lives in fear of Obama.
Hosted on Pass 7
13,117 posts
Gave thanks: 8
Thanked 34 times
|
maybe it's just a typo, but why is the hates in the friendly version in brackets? there doesn't seem to be a code reason in the code version. same with the loves having - beside them.
|
|
|
|
|
|
#4 (permalink) |
|
SurPerson
On a golden path...
Joined in Jul 2004
Lives in front of my laptop
Hosted on Sync
437 posts
Gave thanks: 0
Thanked 1 Time in 1 Post
|
The example is probably just showing different ways of storing data using YAML, since apparantly both end up read the same way.
__________________
Me: TeeJay Server: Sync (Statistics) Site: technoized.com (Statistics) chown -R us ./base |
|
|
|
|
|
#5 (permalink) |
|
Surpass Fan
On a golden path...
Joined in Nov 2004
Lives in San Francisco
364 posts
Gave thanks: 0
Thanked 3 times
|
There are many different ways to do many different things with YAML. It is an impressive spec, and the document I've shown is only a very small subset of the language. Sequences (indexed arrays) can indeed be written as multi-line dashed statements or as elements enclosed within brackets.
http://yaml.kwiki.org/?YamlInFiveMinutes is a good place to look over YAML, in five minutes. |
|
|
|