Home > Backend Development > PHP Tutorial > laravel - What should the standardized PHP class library naming look like?

laravel - What should the standardized PHP class library naming look like?

WBOY
Release: 2016-07-06 13:53:31
Original
1159 people have browsed it

I have seen many open source projects in the form of class.classname.php, but I have also seen many frameworks in the form of classname.class.php. Where should I place this class?

I personally prefer the .class.php form, because in some frameworks, when importing third-party class libraries, the specified class library suffix can be directly specified as .class.php

Reply content:

I have seen many open source projects in the form of class.classname.php, but I have also seen many frameworks in the form of classname.class.php. Where should I place this class?

I personally prefer the .class.php form, because in some frameworks, when importing third-party class libraries, the specified class library suffix can be directly specified as .class.php

  • *.config.php

  • *.function.php

  • *.class.php

The above is suitable for small code, everything is placed in one directory.
If not, such a filename is not needed.

It is recommended to learn about php's psr-4: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md

This is all a matter of usage habits. It is better to write according to PSR-4. After all, composer automatically generates the mapping relationship between the namespace and the source file for you, which is very convenient to use

I personally think that if it is a php file
then it should end with php
There is no need to distinguish between types of files, configuration files, function files
If you want to see it, it is best to look at http:// The projects above packagist.org/
should all end in php!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template