Re: [PHP-PEAR] File naming conventions

[email protected] (Chuck Hagenbuch) Thu, 1 Mar 2001 10:59:19 -0500
Newsgroups php.pear
Message-ID <[email protected]>
Quoting Ulf Wendel <[email protected]>:

> what are the current file naming conventions? I strongly recommend
> naming a file like the class it contains.

Okay, here goes:

- filenames always end in .php
- class names are best illustrated through examples.

If the class is named Cache, then it should live in a file called Cache.php at 
the top level of the pear hierarchy.

If the class is a subclass of Cache - say, Cache_Output - then it should live 
inside a Cache/ directory, and be named Output.php.

If the class is a subclass that should be instantiated by a factory method, and 
never directly, then the same rules apply, but the name of the class itself - 
not the whole hierarchy - should be lowercase. So, a file-based implementation 
of Cache_Container becomes the Cache_Container_file class, and it lives in the 
Cache/Container/file.php file.

Basically, underscores ('_') translate to directories/class hierarchy, and 
everything is studlycaps except:
 - underscores to indicate hierarchy
 - factory subclasses, which have the last part of their name lowercased.


How's that? Someone want to clean up anything that's unclear and toss it into 
CODING_STANDARDS? =)

-chuck

--
Charles Hagenbuch, <[email protected]>
"We have no fuel on board, plus or minus 8 kilograms." -A NASA scientist