|
maxious
|
1 |
# |
|
|
2 |
# S P Y C |
|
|
3 |
# a simple php yaml class |
|
|
4 |
# |
|
|
5 |
# Load this README! |
|
|
6 |
# >> $readme = Spyc::YAMLLoad('README'); |
|
|
7 |
# |
|
|
8 |
--- %YAML:1.1 |
|
|
9 |
title: Spyc -- a Simple PHP YAML Class |
|
|
10 |
version: 0.4.5 |
|
|
11 |
authors: [chris wanstrath (chris@ozmm.org), vlad andersen (vlad.andersen@gmail.com)] |
|
|
12 |
websites: [http://www.yaml.org, http://spyc.sourceforge.net] |
|
|
13 |
license: [MIT License, http://www.opensource.org/licenses/mit-license.php] |
|
|
14 |
copyright: "(c) 2005-2006 Chris Wanstrath, 2006-2009 Vlad Andersen" |
|
|
15 |
tested on: [php 5.2.x] |
|
|
16 |
|
|
|
17 |
installation: > |
|
|
18 |
Copy spyc.php to a directory you can |
|
|
19 |
access with your YAML-ready PHP script. |
|
|
20 |
|
|
|
21 |
That's it! |
|
|
22 |
|
|
|
23 |
about: > |
|
|
24 |
From www.yaml.org: |
|
|
25 |
|
|
|
26 |
"YAML(tm) (rhymes with 'camel') is a human-friendly, cross language, |
|
|
27 |
Unicode based data serialization language designed around the common |
|
|
28 |
native data structures of agile programming languages. It is broadly |
|
|
29 |
useful for programming needs ranging from configuration files to |
|
|
30 |
Internet messaging to object persistence to data auditing. Together |
|
|
31 |
with the Unicode standard for characters, the YAML specification provides |
|
|
32 |
all the information necessary to understand YAML Version 1.1 and to |
|
|
33 |
creating programs that process YAML information. |
|
|
34 |
|
|
|
35 |
YAML(tm) is a balance of the following design goals: |
|
|
36 |
- YAML documents are very readable by humans. |
|
|
37 |
- YAML interacts well with scripting languages. |
|
|
38 |
- YAML uses host languages' native data structures. |
|
|
39 |
- YAML has a consistent information model. |
|
|
40 |
- YAML enables stream-based processing. |
|
|
41 |
- YAML is expressive and extensible. |
|
|
42 |
- YAML is easy to implement." |
|
|
43 |
|
|
|
44 |
YAML makes a lot of sense. It's easy to use, easy to learn, and cool. |
|
|
45 |
As the lucky stiff named why once said, "YAML is a beacon of light." |
|
|
46 |
|
|
|
47 |
If you're new to YAML, may we suggest YAML In Five Minutes: |
|
|
48 |
- http://yaml.kwiki.org/?YamlInFiveMinutes |
|
|
49 |
|
|
|
50 |
If you don't have five minutes, realize that this README is a completely |
|
|
51 |
valid YAML document. Dig in, load this or any YAML file into an array |
|
|
52 |
with Spyc and see how easy it is to translate friendly text into usable |
|
|
53 |
data. |
|
|
54 |
|
|
|
55 |
The purpose of Spyc is to provide a pure PHP alternative to Syck, a |
|
|
56 |
simple API for loading and dumping YAML documents, a YAML loader which |
|
|
57 |
understands a usable subset of the YAML spec, and to further spread |
|
|
58 |
the glory of YAML to the PHP masses. |
|
|
59 |
|
|
|
60 |
If you're at all hesitant ("usable subset of YAML?!"), navigate |
|
|
61 |
http://yaml.org/start.html. Spyc completely understands the YAML |
|
|
62 |
document shown there, a document which has features way beyond the |
|
|
63 |
scope of what normal config files might require. Try it for yourself, |
|
|
64 |
and then start enjoying the peace of mind YAML brings to your life. |
|
|
65 |
|
|
|
66 |
meat and a few potatoes: |
|
|
67 |
- concept: Loading a YAML document into PHP |
|
|
68 |
brief: > |
|
|
69 |
$yaml will become an array of all the data in wicked.yaml |
|
|
70 |
code: | |
|
|
71 |
|
|
|
72 |
include('spyc.php'); |
|
|
73 |
|
|
|
74 |
$yaml = Spyc::YAMLLoad('wicked.yaml'); |
|
|
75 |
|
|
|
76 |
- concept: Loading a YAML string into PHP |
|
|
77 |
brief: > |
|
|
78 |
$array will look like this: |
|
|
79 |
array('A YAML','document in a','string') |
|
|
80 |
code: | |
|
|
81 |
|
|
|
82 |
include('spyc.php'); |
|
|
83 |
|
|
|
84 |
$yaml = '- A YAML\n- document in a\n- string.'; |
|
|
85 |
$array = Spyc::YAMLLoad($yaml); |
|
|
86 |
|
|
|
87 |
- concept: Dumping a PHP array to YAML |
|
|
88 |
brief: > |
|
|
89 |
$yaml will become a string of a YAML document created from |
|
|
90 |
$array. |
|
|
91 |
code: | |
|
|
92 |
|
|
|
93 |
include('spyc.php'); |
|
|
94 |
|
|
|
95 |
$array['name'] = 'chris'; |
|
|
96 |
$array['sport'] = 'curbing'; |
|
|
97 |
|
|
|
98 |
$yaml = Spyc::YAMLDump($array); |
|
|
99 |
|
|
|
100 |
prior art: |
|
|
101 |
- who: [Brian Ingerson, Clark Evans, Oren Ben-Kiki] |
|
|
102 |
why?: > |
|
|
103 |
The YAML spec is really a piece of work, and these guys |
|
|
104 |
did a great job on it. A simple and elegant language like |
|
|
105 |
YAML was a long time coming and it's refreshing to know |
|
|
106 |
such able minded individuals took the task to heart and |
|
|
107 |
executed it with cunning and strength. In addition to |
|
|
108 |
their various noteworthy contributions to YAML parsers |
|
|
109 |
and related projects, YAML.pm's README is a treasure trove |
|
|
110 |
of information for knowledge seekers. Thanks, guys. |
|
|
111 |
|
|
|
112 |
- who: why the lucky stiff |
|
|
113 |
why?: > |
|
|
114 |
As the author of Syck, the code used in Ruby for the language's |
|
|
115 |
YAML class and methods, why is indirectly (directly?) responsible |
|
|
116 |
for my first exposure to YAML (as a config file in a Ruby web-app) |
|
|
117 |
and the countless hours I spent playing with this sheik new data |
|
|
118 |
format afterwards. Syck's README is a YAML file and thus the |
|
|
119 |
inspiration for this file and, even, this very piece of software. |
|
|
120 |
|
|
|
121 |
- who: Steve Howell |
|
|
122 |
why?: > |
|
|
123 |
Python's YAML implementation. PyYAML's README file is also YAML, |
|
|
124 |
so it too inspired the YAML format of this README file. |
|
|
125 |
|
|
|
126 |
- who: [Rasmus Lerdorf, Zeev Suraski, Andi Gutmans, et al] |
|
|
127 |
why?: > |
|
|
128 |
PHP is great at what it does best. It's also paid a lot of my bills. |
|
|
129 |
Thanks. |
|
|
130 |
|
|
|
131 |
bugs: |
|
|
132 |
report: > |
|
|
133 |
Please see Spyc's Sourceforge project page for information on reporting bugs. |
|
|
134 |
speed: > |
|
|
135 |
This implementation was not designed for speed. Rather, it |
|
|
136 |
was designed for those who need a pure PHP implementation of |
|
|
137 |
a YAML parser and who are not overly concerned with performance. |
|
|
138 |
If you want speed, check out Syck. |
|
|
139 |
depth: > |
|
|
140 |
This parser is by no means a comprehensive YAML parser. For supported |
|
|
141 |
features and future plans, check the website. |
|
|
142 |
unicode: > |
|
|
143 |
YAML is supposed to be unicode, but for now we're just using ASCII. |
|
|
144 |
PHP has crappy unicode support but who knows what the future holds. |
|
|
145 |
|
|
|
146 |
resources: |
|
|
147 |
- http://www.yaml.org |
|
|
148 |
- http://www.yaml.org/spec/ |
|
|
149 |
- http://yaml.kwiki.org/?YamlInFiveMinutes |
|
|
150 |
- http://www.whytheluckystiff.net/syck/ |
|
|
151 |
- http://yaml4r.sourceforge.net/cookbook/ |
|
|
152 |
|
|
|
153 |
thanks: |
|
|
154 |
- Adam Wood |
|
|
155 |
- Daniel Ferreira |
|
|
156 |
- Aaron Jensen |
|
|
157 |
- Mike Thornton |
|
|
158 |
- Fabien Potencier |
|
|
159 |
- Mustafa Kumas |