By default, any file that PHP touches is usually suffixed with
.php. It's universally understood by Apache / Nginx as the default for PHP files and most setups expect PHP files to end in this extension. In short,
.php is the standard for everything PHP.
However, I'm wondering if perhaps view files should have a different extension to help differentiate them from other PHP files.
First, when it comes to views I have found that almost all MVC frameworks using a matching view file named after the controller or method. In addition, you generally also have a matching model named the same thing. This causes a problem with most IDE's and editors.
For example, you might have a "user" controller, a "user" view, and a "user" model. The results in having three files open called "user.php" which makes it a bother when you are moving around and clicking on the wrong tabs.
Second, separating views as a fundamentally different kind of PHP file (the presentation type) is another argument for changing the extension of the view files to something other than
.php. Something that immediately tells your brain what type of content belongs in it.
Third, some applications expose parts (or all) of the PHP files in the webroot and it's directories. Rather than adding something like
<?php if(!defined(ABC)) die('not allowed'); it would be nice to have an easy way to forbid access to views while allowing other files like the customary
Are there any other good/bad reasons to think it's a good idea to change the file extension of view files?