Php file naming
There is no definitive naming convention in PHP and they can differ in structure. If you are not using a framework, you can use one of the popular ones:
- with_underscores
- PascalCased
- camelCased
This table can be helpful and tell you more about naming (not only file names, but also class, method and function names):
╔═══════════════════════╦═════════════╦════════════╦══════════════╦════════════╦════════════╗
║ PHP Project ║ Classes ║ Methods ║ Properties ║ Functions ║ Variables ║
╠═══════════════════════╬═════════════╬════════════╬══════════════╬════════════╬════════════╣
║ Akelos Framework ║ PascalCase ║ camelCase ║ camelCase ║ lower_case ║ lower_case ║
║ CakePHP Framework ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
║ CodeIgniter Framework ║ Proper_Case ║ lower_case ║ lower_case ║ lower_case ║ lower_case ║
║ Concrete5 CMS ║ PascalCase ║ camelCase ║ camelCase ║ lower_case ║ lower_case ║
║ Doctrine ORM ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
║ Drupal CMS ║ PascalCase ║ camelCase ║ camelCase ║ lower_case ║ lower_case ║
║ Joomla CMS ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
║ modx CMS ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ lower_case ║
║ Pear Framework ║ PascalCase ║ camelCase ║ camelCase ║ ║ ║
║ Prado Framework ║ PascalCase ║ camelCase ║ Pascal/camel ║ ║ lower_case ║
║ SimplePie RSS ║ PascalCase ║ lower_case ║ lower_case ║ lower_case ║ lower_case ║
║ Symfony Framework ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
║ WordPress CMS ║ ║ ║ ║ lower_case ║ lower_case ║
║ Zend Framework ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
╚═══════════════════════╩═════════════╩════════════╩══════════════╩════════════╩════════════╝
Remember that you agree to the naming convention.
source to share
There is no specific naming convention for core php files to use your own naming convention, but you can name it based on how your file works.
Like php file only html is displayed and then given my_file_view.php
if it has a database operation thenmy_file_db.php
etc. for a function and for other specifications you can use it.
source to share
Usually you need to accept 2 agreements:
- used infrastructure
- PSR-4
At best, these 2 are the same. I usually try to avoid cases where the environment is trying to force some custom rules.
In any case, the main thing is to remain constant throughout the entire project. Once you choose a convention to follow, stick to it until you start working on another project. There is nothing worse than different naming conventions in the same project, it doesn't matter if we're talking about files, classes, methods, etc. Be consistent.
source to share