It would be great if the core and the extensions uses the PSR (0,1,2) programming and code styling guide.

More infos at Github and in the Google group.

Dumb question — where is the actual style guide?

Sorry, here the direct links:

Wow ... this could be great :) I'm finding myself inventing autoloaders as I need them ...

You might like to chime in on #859. We've been aware for a while that everyone has different styles, and Symphony doesn't really dictate a preferred style, so the it can be difficult for a new developer looking to get started in the code.

If I'm not mistaken PSR is geared towards PHP5.3 code mainly? Unfortunately we don't have this flexibility just yet but there is other recommendations that can be taken from those documents as well in the meantime.

Buh, I hate PSR styling guides. They are just too inconsistent in my opinion:

function bar($arg1)
    // body here


if ( expression ) {
    // body here

Really? Come on! How on earth can you work like this?

Really? Come on! How on earth can you work like this?

Most of the major frameworks use this style since years. It is our daily work to use the K&R style.

I agree with Huib there, it's either one or the other IMO.

I agree with Huib as well. And I don't mind how many frameworks use that inconsistent stuff.

The majority of the PSR style seems fine to me. I too prefer braces on the same line all the time, but that's just a minor difference from some otherwise fairly consistent guidelines.

I'm going to disagree with Huib (and the rest of you) — putting the brace on a new line for functions, but not flow control makes it quick and easy to distinguish the difference between the two.

It's not inconsistent — it's just not what you use. I'm not actually going to read the PSRs though — because, like, ugh: PHP :P

If code is indented according to scope (such that class statements are not indented, method statements inside classes are indented once, flow control statements inside methods are indented twice, etc.), then indentation tells you everything you need to know, so there would be no reason for the curly braces for classes, methods, and flow control statements to be treated differently.

My intention was not to discuss where stands a brace. I just wanted to overcome the different coding standards of the various systems (cms and frameworks).

We have already to fight with the inconsistency of PHP itself. So we need no inconsistency in "our own" systems.

Learn once, use many times. Simplification for all!

Sorry, I have caused the off-topic-ness. From what I have looked at in the core, I think it is pretty consistent. Of course, in some parts there are differences like if (expression) vs if(expression).

However, I think these differences are minor, and a bigger problem is coding style in general. I, for one, am a big fan of many small functions, while others use less, but bigger functions. Also, there seems to be a big difference in error handling, input checking, documenting and dependency handling.

In my opinion, those differences are way more important than the exact placement of the accolades and spaces. I can read and understand pretty much all 'graphical' styles, but I do have a problem understanding some 'functional' styles. The only problem is that getting those styles to match is very difficult.

In my opinion, those differences are way more important than the exact placement of the accolades and spaces.

Absolutely. Code structure is far more important than where spaces and braces go in my opinion. Consistency is always good, but with extensions at least, allowing the author's own style seems fine.

Once or twice we've had big pull requests for the Symphony core which have been refused because the spaces and braces do not match the existing style (tabs vs spaces etc.). Having a documented style guide would be useful in directing people towards consistency. But in my experience, when I'm working on someone else's codebase, I adapt to use their style — just do what they do :-P


That's the point: Coding styles are a good first step, but we need more - we need coding standards!

More infos: Moonspot - Brian Moons blog: "PHP Coding Standards" (look also in the comments!)

You can give php_codesniffer a shot. There's also a PSR ruleset out there (default is PEAR) but you can also create you own rulesets. Pretty easy to include into vim (e.g. with the syntastic plugin), and I guess a bunch of other editors/IDEs can handle it, too.

PSR-1 and PSR-2 proposel are out:

More infos:

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details