README 5.6 KB

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