SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 52

Thread: Yaml

Hybrid View

  1. #1
    SitePoint Zealot crashmakerMX's Avatar
    Join Date
    Jun 2005
    Location
    Germany
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Yaml

    Hi,

    has someone of you used YAML for configuration or something? Symfony and Rails use it, there are two parsers for PHP for it and it looks interesting as far as I can tell.

    Any experiences or suggestions?

    Maxx

  2. #2
    SitePoint Wizard dreamscape's Avatar
    Join Date
    Aug 2005
    Posts
    1,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think Symfony uses it because Rails does, to be honest with you. Rails uses it most likely because Ruby has core support for YAML, and it is kind of the "de facto" format to use in Ruby.

    If you looking for a simple configuration style to use with PHP, I'd just use a simple INI style, which PHP has built in support for parsing (not the greatest built in, but it can be expanded upon if needed).

  3. #3
    SitePoint Zealot crashmakerMX's Avatar
    Join Date
    Jun 2005
    Location
    Germany
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Configuration file format isn't an issue - if I don't find something better, I'll just use plain PHP.

    I am more looking for a format to control code generation - XML is an option, but it's a bit talkative.

  4. #4
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by crashmakerMX
    Configuration file format isn't an issue - if I don't find something better, I'll just use plain PHP.

    I am more looking for a format to control code generation - XML is an option, but it's a bit talkative.
    Why not use ini syntax? http://www.php.net/parse_ini_file

  5. #5
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    Toronto
    Posts
    300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BerislavLopac
    Why not use ini syntax? http://www.php.net/parse_ini_file
    You realize that ini syntax, while useful, has many limitations in terms of the structures that can be represented, yes?

  6. #6
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jayboots
    You realize that ini syntax, while useful, has many limitations in terms of the structures that can be represented, yes?
    Absolutely, but there is rarely a need for more than two levels and long values, as fas as I am aware...

  7. #7
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    Toronto
    Posts
    300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use it and I love it. I have been using Spyc as it is usable and doesn't require an extension. As I use it for configurations and I want to try to limit the amount of processing overhead, I add a compiler step (a simple var_export) and write to a php file. The compiler can also mash several configuration files together which is also handy (both for inheritance and for reducing the number of files to open).

    YAML makes sense to me -- easy to read, easy to write, concise (ie: small) and rather flexible. Another benefit: YAML happens to be a superset of JSON.

  8. #8
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why not plain php ? I mean - that's what YAML is to ruby, and JSON to javascript. Thoose languages just have a clearer syntax in that respect.

  9. #9
    SitePoint Zealot crashmakerMX's Avatar
    Join Date
    Jun 2005
    Location
    Germany
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken
    Why not plain php ? I mean - that's what YAML is to ruby, and JSON to javascript. Thoose languages just have a clearer syntax in that respect.
    I'm thinking of a code generator that allows non-PHPers to create simple applications. Therefore using PHP is not a real option.

  10. #10
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by crashmakerMX
    I'm thinking of a code generator that allows non-PHPers to create simple applications.
    What about RTF files?. You at least ought to be able to generate an UI shell from this kind of requirements document.

    Arbiter is kind of stalled at the moment due to time pressures but it will get moving again soon.

  11. #11
    SitePoint Guru
    Join Date
    May 2005
    Location
    Finland
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken
    Why not plain php ? I mean - that's what YAML is to ruby --
    I think YAML is to Ruby what INI is to PHP. Json is different from the two in that it happens to be valid Javascript. The other two just have built-in interpreters in their respective languages. INI only happens to be unfit for describing hierarchies of data, unlike the other two. Which is a shame if you ask me, because that is a limitation we'll inevitably end up needing to circumvent in a way or another.

  12. #12
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not being a rubyist myself, I actually though that YAML was valid ruby syntax (like JSON). In that case, YAML may make a bit more sense in the PHP-world, but really - why not XML ? PEAR::XML_Unserializer makes it trivial even on php4.

  13. #13
    SitePoint Zealot crashmakerMX's Avatar
    Join Date
    Jun 2005
    Location
    Germany
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    XML is very talkative, IMHO.

  14. #14
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by kyberfabrikken
    Not being a rubyist myself, I actually though that YAML was valid ruby syntax (like JSON). In that case, YAML may make a bit more sense in the PHP-world, but really - why not XML ? PEAR::XML_Unserializer makes it trivial even on php4.
    XML: slow, verbose, and easy to overload/bloat. It's also not very friendly to newbies who will have "no coding knowledge".

    It is quite portable though, but that's not really necessary for application configuration unless you're copying someone else's setup (i.e. Tomcat's server.xml).

    PS: I say this as someone who has worked with a LOT of XML/XSL over the past few years.

  15. #15
    SitePoint Wizard Ren's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    1,060
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about use (X)HTML or subset of ?

    Code:
    <ol id="something"><li>A</li><li>B</li></ol>
    
    becomes 
    
         array('something' => array('A', 'B'));

  16. #16
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    Worcester
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The biggest problem with XML for configuration imo is how tedious it is to write.

  17. #17
    SitePoint Wizard Ren's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    1,060
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by akrabat
    The biggest problem with XML for configuration imo is how tedious it is to write.
    SGML ?

    <databaseDriver>mysql</>
    <databaseName>foo</>
    <user>root</>


    ... just kidding... I don't think what to go near that can of worms..

  18. #18
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by akrabat
    The biggest problem with XML for configuration imo is how tedious it is to write.
    While I tend to agree on that, it has so many other benefits, and if the person going to edit it isn't a programmer, he's not going to use a texteditor anyway - he'll be using an xml-editor.

    Quote Originally Posted by vgarcia
    It's also not very friendly to newbies who will have "no coding knowledge".
    Yes and no. It's easy to break stuff if you edit it as text, but you'll know it right away. It reduces the chance of errors, since it's less ambiguos. If you need your non-tech users to edit the config-files, you can provide a DTD, and set them up with an xml-editor. How's that compared to editing a text-file ?

  19. #19
    SitePoint Wizard dreamscape's Avatar
    Join Date
    Aug 2005
    Posts
    1,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by akrabat
    The biggest problem with XML for configuration imo is how tedious it is to write.
    Not really. If you're used to writing XHTML, then a simple XML schema is easier to write and deal with than an XHTML page. At the very worst, no more difficult than writing XHTML, IMO.

    crashmakerMX, if your goal is to make something that allows people who don't know PHP to make PHP applications, then what does it matter what format this is? Because, if it is going to work, then I think you are going to want to hide everything, including this, from them.

  20. #20
    SitePoint Zealot crashmakerMX's Avatar
    Join Date
    Jun 2005
    Location
    Germany
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @McGruff: Human written text is not very machine-readable. And I would use OpenDocument under any circumstances.

    @Ren: Well, what's the advantage over XML?

  21. #21
    SitePoint Wizard Ren's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    1,060
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by crashmakerMX
    @Ren: Well, what's the advantage over XML?
    Viewing is easier, just open in a browser, more familiar element names, rather than aload of custom ones. Could possibly become a microformat.

    @vgarcia: Not sure I'd completely agree that XML itself is slower than any other format. But significantly better engineered, say for I know XML can handle utf-8 data, but parse_ini ? How knows..

  22. #22
    SitePoint Zealot crashmakerMX's Avatar
    Join Date
    Jun 2005
    Location
    Germany
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ren
    Viewing is easier, just open in a browser, more familiar element names, rather than aload of custom ones. Could possibly become a microformat.
    It might be easier to view in a browser, but the syntax will also be even more talkative. It doubt someone wants to embed code generation definitions in a web page.

    Quote Originally Posted by Ren
    @vgarcia: Not sure I'd completely agree that XML itself is slower than any other format. But significantly better engineered, say for I know XML can handle utf-8 data, but parse_ini ? How knows..
    Why shouldn't it work? The parts the parser has to operate on (the "markup") is ASCII and therefore UTF-8 compatible.


    We are going a bit off topic.

  23. #23
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Ren
    @vgarcia: Not sure I'd completely agree that XML itself is slower than any other format. But significantly better engineered, say for I know XML can handle utf-8 data, but parse_ini ? How knows..
    Let's take the world's simplest configuration, in 2 formats.

    XML:
    HTML Code:
    <?xml version='1.0' encoding='utf-8'?>
    <config>
    <enabled>true</enabled>
    </config>
    A properties file (similar to an INI file, used a lot in Java apps):
    Code:
    enabled=true
    Which would cause more overhead in parsing?

    XML's not without use; I just think simple application config isn't the best use for it. If you find that you need to represent complex structures in your app config that ini files or yaml or whatever can't provide, then by all means use XML, but odds are if your app config is that complex it can be simplified.

  24. #24
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by akrabat
    The biggest problem with XML for configuration imo is how tedious it is to write.
    I would agree with you if there wasn't so many useful XML tools around.

  25. #25
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Umm...

    Has to be XML for the more flexible and functional option; For real programmers, there's really no other choice in the matter


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •