Laravel-What should the canonical PHP class library name look like?

Source: Internet
Author: User
Tags php class
I've seen a lot of open source projects that are class names. php in this form, but also seen in many frameworks inside is the class name. class.php, what's the best place to put this class?

I personally prefer. The form of class.php, because such a third-party class library is imported in some frameworks specifies that the class library suffix can be specified directly as. class.php

Reply content:

I've seen a lot of open source projects that are class names. php in this form, but also seen in many frameworks inside is the class name. class.php, what's the best place to put this class?

I personally prefer. The form of class.php, because such a third-party class library is imported in some frameworks specifies that the class library suffix can be specified directly as. class.php

    • *.config.php

    • *.function.php

    • *.class.php

The above is suitable for small code use, everything is left in a directory.
If not, you do not need a file name like this.

Recommended to understand the next PHP psr-4: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md

This is the use of the habit of the question, or according PSR-4 to write better, after all, there is composer automatically help you to generate a namespace and the source file mapping relationship, easy to use

I personally think that if it is a PHP file
Well, that would be the end of PHP.
There's no need to distinguish between class file profile function files
If you want to see it, it's best to look at the http://packagist.org/item.
It should all end in PHP!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.