Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript and PHP filename coding conventions

I would like to know the popular ways of naming files in JavaScript and PHP development. I am working on a JS+PHP system, and I do not know how to name my files.

Currently I do for JS:

framework/
framework/widget/
framework/widget/TextField.js (Framework.widget.TextField())
Framework.js (Framework())

So, my folders are lowercase and objects CamelCase, but what should I do when the folder/namespace requires more than one word? And what about PHP?

jQuery seems to follow:

jquery.js
jquery.ui.js
jquery.plugin-name.js

so that it is

jquery(\.[a-z0-9-])*\.js

but ExtJS follows completely different approach. Douglas Crockford only gives us details about his preference for syntax conventions.

like image 365
Tower Avatar asked Oct 15 '22 04:10

Tower


1 Answers

Personally I'd go for all lower case names for the folders, separating words with "-" as per jQuery, but that's without any evidence to back it up.

However, what ever system you choose, be consistent. This will not only help you 6 months down the line, but will help someone coming to your system. They'll soon learn their way around even if it's not 100% the same as other systems they've used in the past.

like image 129
ChrisF Avatar answered Oct 19 '22 03:10

ChrisF