How to get Composer (PSR-4) to work with the extension .class.php?

I had a big problem with the "Class Not Found" error. But recently I realized the original problem. My previous two questions on this issue: -

Composer gives an error, "Class Not Found"

PHP Composer PSR-4 Startup and subspace spaces, class not found

I am interested in working with extension classes class.php, for example. parent.class.phpand child.class.php. But the composer does not seem to recognize these files, and the message "Class Not Found" is displayed. Problem solved, if I use a simple extension .php ( child.phpand parent.php).

I was wondering if it is possible to make a composer with the extension .class.phpfor my php class files?

+1
source share
1 answer

If you want your code to be compatible with PSR-4, you MUST have your names in format classname.php.

From the PSR-4 specification:

The final class name matches the name of the file ending in .php. The file name MUST match the case of the trailing class name.

( http://www.php-fig.org/psr/psr-4/ )

So, if you stick to PSR-4, then the answer is that you cannot use your file names .class.php. Just change the file names and the problem will be solved.

- , , . ( , PSR-4, )

+2

All Articles