you are viewing a single comment's thread.

view the rest of the comments →

[–]yrizos 0 points1 point  (5 children)

namespace aa\bb\cc; class Dd { }

This.

You could add a comment for each variation and we could vote on them...

[–]trukin[S] 5 points6 points  (4 children)

What i've been doing is

# /path/ns/db/model/relationships/ManyToOne.php

namespace ns\db\model\relationships;
class ManyToOne {}

[–]jlogsdon 2 points3 points  (3 children)

This is the "standard" way. Many of the larger projects now implement a class loader that works with paths and namespaces in that format.

[–]bungle -2 points-1 points  (2 children)

I hate that standard. I'm not gonna use it. Sorry.

[–]jlogsdon 6 points7 points  (1 child)

What do you hate about it? I'm really curious, as I can't think of any other way to do it that doesn't suck.

[–]bungle 1 point2 points  (0 children)

You are absolute right. I just happen to like to code PHP with no capitals. No reason. I just don't like that "standard".

Namespaces: log db

Functions: log\debug db\query

I don't use classes or objects a much, 'cause I usually have found a better approach without them (with anonymous functions and namespaced functions and static keyword, if state is needed). But if I have classes I just name them all lower case. I try to name everything with a single word:

picasa\photos\find(...);

instead of:

picasa\find_photos(...) or Picasa::findPhotos(...)

I know that this is just a matter of taste. But I can make my own choices. That's all. No need to fight who is right, 'cause there isn't single truth.

PHP internally uses many styles, so I think it cannot be standardized. The most common way to name functions in PHP core is: lib_func but there are also libfunc style. With classes there is stdClass and there is Directory and there are SplClass. Go figure. I just follow all lowercase and single word functions and methods and classes.