Home >Backend Development >PHP Tutorial >PHP PSR-4 Autoloader automatically loads the Chinese version nt6 oem loader loader activation tool skse loader

PHP PSR-4 Autoloader automatically loads the Chinese version nt6 oem loader loader activation tool skse loader

WBOY
WBOYOriginal
2016-07-29 08:54:031736browse

Autoloader

Keywords "MUST", "MUST NOT", "REQUIRED",
"SHALL", " "SHALL NOT"), "should" ("SHOULD"), "should not" ("SHOULD NOT"),
"recommended" ("RECOMMENDED"), "can" ("MAY") and" A detailed description of "OPTIONAL" can be found in [RFC 2119][].

1. Overview

This PSR is a specification related to automatic loading of corresponding classes by file path.
This specification is interoperable and can be used as a supplement to any automatic loading specification, including PSR-0. In addition ,
This PSR also includes the file storage path specification corresponding to the automatically loaded class.

2. Detailed description

  1. The "class" here generally refers to all classes, interfaces, traits reusable code blocks and other similar structures.

  2. A complete class name needs to have the following structure:

    <code>\<span><<span>命名空间</span>></span>(\<span><<span>子命名空间</span>></span>)*\<span><<span>类名</span>></span></code>
    1. The complete class namemusthave a top-level namespace, called "vendor namespace";

    2. The complete class name Can have one or more sub-namespaces;

    3. The complete class name must have a final class name;

    4. The underscore in any part of the complete class name has no special meaning;

    5. The complete class name can consist of any uppercase and lowercase letters;

    6. All class names must be case-sensitive.

  3. When loading the corresponding file based on the complete class name...

    1. In the complete class name, remove the first namespace separator, one or more consecutive namespaces and sub-namespaces in front , as a "namespace prefix", it must correspond to at least one "file base directory";

    2. The sub-namespace immediately following the namespace prefix must match the corresponding "file base directory", where The namespace separator will be used as the directory separator. The class name

      at the end of
    3. must have the same name as the corresponding file with the suffix .php.

    4. The implementation of the autoloader must not throw an exception, must not trigger any level of error message, and should not have a return value.

3. Example

The following table shows the file paths corresponding to the complete class name, namespace prefix and file base directory that comply with the specification. /ac me-log-writer/lib/

./acme -log-writer/lib/File_Writer.php

SymfonyCoreRequestZendAclNote: Examples are not part of the specification and may be changed at any time. The above introduces the PHP PSR-4 Autoloader to automatically load the Chinese version, including the loader content. I hope it will be helpful to friends who are interested in PHP tutorials.
AuraWebResponseStatus AuraWeb /path/to/aura-web/src/ /path/to/aura-web/src/Response/Status.php
SymfonyCore ./vendor/Symfony/Core/ ./vendor/Symfony/Core/Request.php
Zend /usr/includes/Zend/ / usr/includes/Zend/Acl.php
For the implementation of this specification, please refer to Related Examples
Statement:
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