TP Frame Auto-load priority

Source: Internet
Author: User

$map = Array ('think\log'=>think_path.' think\log.php ','org\util\array'=>think_path. ' org\util\array.php ' ); Think\think::addmap ($MAP);

In the case of the Test\myclass class, the order of precedence for automatic loading is as follows:

1. In alias.php or Addmap method, decide whether to register

The Test\myclass class map, if any, automatically loads the file defined by the class library mapping;

2. Determine if there is a library/test directory, and then load the directory as the initial directory;

3. Determine if there is a registered test root namespace, and then the registered directory for the initial directory load;

4. If none of the above is true, the initial directory load is done with test as the module;

About automatic loading

1. Add any new directory below the library directory = automatically register as a new root namespace.

2. Register the new root namespace.

'Autoload_namespace'=Array ('My'= = Think_path.'My',    ' One'= = Think_path.' One',)
new My\Net\IpLocation();

new One\Util\Log();

3. Class Library mappings. Addmap method and alias.ph configuration file.

$map = Array ('think\log'=>think_path.' think\log.php ','org\util\array'=>think_path. ' org\util\array.php ' ); Think\think::addmap ($MAP);

TP Frame Auto-load priority

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.