Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm developing a simple CMS which I'd like to make it open source.

For the file structure, do you think it's safe to use names like:

AppData
FileUploads

instead of

app-data
file-uploads

?

Because I heard some servers have problems with the camelCase.

share|improve this question
    
Based on stackoverflow.com/questions/4961923/… I'd say you're better off sticking to lowercase. –  Tass May 20 '12 at 23:39
1  
What have you heard about problems with camelcase? Maybe what you heard is not correct or based on actual facts. –  Victor May 21 '12 at 0:00
    
Why not follow the Microsoft Model and unnecessarily put spaces in the names: "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin" Sysadmins will love you for that one! :-P –  Kevin McCormick May 21 '12 at 15:00
    
Er, CakePHP 2.0 has moved to entirely camelCased file names without trouble –  Ben Brocka May 21 '12 at 15:10
add comment

3 Answers

There are a few different naming conventions knocking about, but personally I don't see any problem with using upper-case letters in file names.

If you're using autoloaders (which you should), then you're very likely to need to use upper-case letters. Again, it depends on how you name classes, but most people begin all class names with a capital. Of course you could use strtolower() in your autoloader function, but that's just messy.

So in summary, if you're using OOP, then you should be using upper-case letters in file names. But I'd probably stay away from upper-case letters in file names that aren't classes- again, just convention.

share|improve this answer
add comment

Anytime you use mixed case in file names on *nix systems you are asking for human error to slip in. All lower case is easier to type in and not make mistakes. It also causes subtle errors and undefined type behaviors on Case Preserving but Case Insensitive file systems the default modes of NTFS and HFS+.

I would be more concerned about using the - character in file names than mixed case. - is a command line switch and I have have experienced some extremely subtle issues with shells and command line programs where this will need to be escaped, this was a long while ago and related to PowerShell parsing command line args to other command line programs, but still I wouldn't do it just to avoid tracing down silly things like that.

Traditionally _ is the preferred word separator in file and directory names.

There is actually a specification for Unicode Word Boundaries.

share|improve this answer
    
What about PHP autoloaders? If you've camelcased a class name, then the autoloader will get a camelcased name as the basis for locating the class in the filesystem. Unless you explicitly strtolower() the class name the system will be looking for camelcased filenames. –  GordonM May 21 '12 at 7:33
2  
File names starting with - can cause problems. I don't know of any potential problems with embedded - characters, as in foo-bar.txt. –  Keith Thompson May 21 '12 at 7:58
    
I have to state that NTFS is case sensitive - support.microsoft.com/kb/100625 - My favorite trick on NT4 and Win2K was to turn on POSIX compliance and confuse people who believed it was not true. (Note Today you have use Win7 Enterprise or Win2008R2 to even have the ability to do that) –  mangelo May 21 '12 at 14:26
2  
The part you missed is NTFS supports two slightly different modes of operation that can be selected by the subsystem of the application interacting with NTFS. The first is fully case sensitive and demands that file names supplied by the application match the names stored on disk including case if the file on disk is to be selected. The second mode of operation is case preserving but not case sensitive. The part in bold is only what is supported as the default in Windows. So as I stated NTFS is Case Preserving but still Case InSensitive as well, this has always been the case. –  Jarrod Roberson May 21 '12 at 14:28
    
I agree with the first part of your answer, but since he is creating a CMS, are underscores really preferable if the file/directory names become a part of URLs? –  IQAndreas Dec 20 '13 at 11:49
add comment

Short answer, yes with an if.

More specifically, some filesystems are case-sensitive (foo.php and FOO.PHP would be different files), whilst others aren't (foo.php and FOO.PHP would be the same file).

If you're developing on a system with a case-sensitive filesystem (most Linux filesystems, HFS+ in Case Sensitive mode, etc) then you shouldn't have any problems.

If, however, you're working on a system with a case-insensitive filesystem (NTFS, HFS+ in its default configuration, etc) then you need to keep a careful eye on the filenames. You can run into problems where a file loads on one machine but causes a file not found error on another. Depending on the criticality of the file, this can cause problems that range from annoyances to show-stopping failures, but it will cause problems.

If you're developing on Linux, you can probably don't have to worry about it. If not, then you probably do, but there's nothing stopping you from using camel cased filenames.

EDIT: If you're using an autoloader then it's generally a good idea for your class filename casing to match the PHP class name casing. The autoloader automatically gets the class name as an argument and has to figure out what file to open to find it. Of course you can do anything you like an an autoloader to resolve the class name, but most autoloaders just map the class name onto a filename. Unless you explicitly change the case of the class name in the autoloader that means that a request for a new FooClass will probably attempt to open a FooClass.php file.

The best advice I can offer is use whatever casing convention you want, but be sure to test it on both case sensitive and case insensitive filesystems if at all possible.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.