Is there any convention for naming php files?
Not talking about php class files, but files that are mostly HTML with some php inside them.
Should it be my-file-example.php
PSR-4 recommends using a directory hierarchy to represent the namespace.
For Object-Oriented programming, the autoloader can simplify code management with relatively little cost overhead at run time. This requires the capability to determine a file path from a class name - hence a linear transform of the latter is a good idea. This might be as simple as $className . ".php"
I would suggest you to use underscore separators my_file_example.php
, CodeIgniter for example use this convention for it's view files.
With dashes, some IDE/Text Editor don't select all the filname by double clicking on it, while with underscore it select, generally, all the file name.
There are usually 2 conventions you need to take into consideration:
In best scenario these 2 are the same. I usually try to avoid cases when a framework tries to force some custom rules.
Either way, the MOST important is to stay consistent throughout the project. Once you pick a convention to follow, stick with it until you start working on a different project. There's nothing worse than different naming conventions in a single project, doesn't matter if we're talking about files, classes, methods or whatever. Be consistent.
There is no specific for the core php files you have to use your own naming convention, but you can name on the bases of you file work.
Like php file is only display the html then give my_file_view.php
if it has database operation then my_file_db.php
and so on for the function and for other specification you can use it.
There is no really convention for PHP files.
You just should keep the same in your project.
I recommand you to use camelCase.
You'll come across packages using filenames as
class.phpmailer.php or
ImapMailbox.php
(both containing classes with ClassName {})
(Personally, I use camelCase heavily for fnames, from var-habits i guess. )