PHP vendor自动加载分析


PHP vendor自动加载分析


正文

PHP中使用Composer进行依赖包管理,下载的包都放入了vendor文件夹,但是我们实例化一个类时,这个类是怎么加载进来的呢?

可以先看一下 PSR4 https://ibaiyang.github.io/blog/php/2022/04/03/PHP中PSR规范.html#psr-4-自动加载规范

还有《深入理解Yii2.0 类自动加载机制》 https://ibaiyang.github.io/blog/yii2/2019/06/24/深入理解Yii2.0-类自动加载机制.html

这个也是 Composer 下载依赖包后自动加载的逻辑分析。

一般在项目入口文件 index.php中我们都有一行:

require __DIR__ . '/../vendor/autoload.php';

这个文件是关键,autoload.php 的文件内容:

<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit82c3996fbc74c498b11153bcc8cd8e49::getLoader();

autoload.php这个文件是Composer生成和更新的,在 vendor 根文件夹下。 下面其他文件在 vendor/composer 文件夹下。

autoload_real.php

看下 autoload_real.php 的文件内容:

<?php

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit82c3996fbc74c498b11153bcc8cd8e49
{
    private static $loader;

    public static function loadClassLoader($class)
    {
        if ('Composer\Autoload\ClassLoader' === $class) {
            require __DIR__ . '/ClassLoader.php';
        }
    }

    public static function getLoader()
    {
        if (null !== self::$loader) {
            return self::$loader;
        }

        spl_autoload_register(array('ComposerAutoloaderInit82c3996fbc74c498b11153bcc8cd8e49', 'loadClassLoader'), true, true);
        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
        spl_autoload_unregister(array('ComposerAutoloaderInit82c3996fbc74c498b11153bcc8cd8e49', 'loadClassLoader'));

        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
        if ($useStaticLoader) {
            require_once __DIR__ . '/autoload_static.php';

            call_user_func(\Composer\Autoload\ComposerStaticInit82c3996fbc74c498b11153bcc8cd8e49::getInitializer($loader));
        } else {
            $map = require __DIR__ . '/autoload_namespaces.php';
            foreach ($map as $namespace => $path) {
                $loader->set($namespace, $path);
            }

            $map = require __DIR__ . '/autoload_psr4.php';
            foreach ($map as $namespace => $path) {
                $loader->setPsr4($namespace, $path);
            }

            $classMap = require __DIR__ . '/autoload_classmap.php';
            if ($classMap) {
                $loader->addClassMap($classMap);
            }
        }

        $loader->register(true);

        if ($useStaticLoader) {
            $includeFiles = Composer\Autoload\ComposerStaticInit82c3996fbc74c498b11153bcc8cd8e49::$files;
        } else {
            $includeFiles = require __DIR__ . '/autoload_files.php';
        }
        foreach ($includeFiles as $fileIdentifier => $file) {
            composerRequire82c3996fbc74c498b11153bcc8cd8e49($fileIdentifier, $file);
        }

        return $loader;
    }
}

function composerRequire82c3996fbc74c498b11153bcc8cd8e49($fileIdentifier, $file)
{
    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
        require $file;

        $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
    }
}

ClassLoader.php

ClassLoader.php 文件内容:

<?php

/*
 * This file is part of Composer.
 *
 * (c) Nils Adermann <naderman@naderman.de>
 *     Jordi Boggiano <j.boggiano@seld.be>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Composer\Autoload;

/**
 * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
 *
 *     $loader = new \Composer\Autoload\ClassLoader();
 *
 *     // register classes with namespaces
 *     $loader->add('Symfony\Component', __DIR__.'/component');
 *     $loader->add('Symfony',           __DIR__.'/framework');
 *
 *     // activate the autoloader
 *     $loader->register();
 *
 *     // to enable searching the include path (eg. for PEAR packages)
 *     $loader->setUseIncludePath(true);
 *
 * In this example, if you try to use a class in the Symfony\Component
 * namespace or one of its children (Symfony\Component\Console for instance),
 * the autoloader will first look for the class under the component/
 * directory, and it will then fallback to the framework/ directory if not
 * found before giving up.
 *
 * This class is loosely based on the Symfony UniversalClassLoader.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 * @author Jordi Boggiano <j.boggiano@seld.be>
 * @see    http://www.php-fig.org/psr/psr-0/
 * @see    http://www.php-fig.org/psr/psr-4/
 */
class ClassLoader
{
    // PSR-4
    private $prefixLengthsPsr4 = array();
    private $prefixDirsPsr4 = array();
    private $fallbackDirsPsr4 = array();

    // PSR-0
    private $prefixesPsr0 = array();
    private $fallbackDirsPsr0 = array();

    private $useIncludePath = false;
    private $classMap = array();
    private $classMapAuthoritative = false;
    private $missingClasses = array();
    private $apcuPrefix;

    public function getPrefixes()
    {
        if (!empty($this->prefixesPsr0)) {
            return call_user_func_array('array_merge', $this->prefixesPsr0);
        }

        return array();
    }

    public function getPrefixesPsr4()
    {
        return $this->prefixDirsPsr4;
    }

    public function getFallbackDirs()
    {
        return $this->fallbackDirsPsr0;
    }

    public function getFallbackDirsPsr4()
    {
        return $this->fallbackDirsPsr4;
    }

    public function getClassMap()
    {
        return $this->classMap;
    }

    /**
     * @param array $classMap Class to filename map
     */
    public function addClassMap(array $classMap)
    {
        if ($this->classMap) {
            $this->classMap = array_merge($this->classMap, $classMap);
        } else {
            $this->classMap = $classMap;
        }
    }

    /**
     * Registers a set of PSR-0 directories for a given prefix, either
     * appending or prepending to the ones previously set for this prefix.
     *
     * @param string       $prefix  The prefix
     * @param array|string $paths   The PSR-0 root directories
     * @param bool         $prepend Whether to prepend the directories
     */
    public function add($prefix, $paths, $prepend = false)
    {
        if (!$prefix) {
            if ($prepend) {
                $this->fallbackDirsPsr0 = array_merge(
                    (array) $paths,
                    $this->fallbackDirsPsr0
                );
            } else {
                $this->fallbackDirsPsr0 = array_merge(
                    $this->fallbackDirsPsr0,
                    (array) $paths
                );
            }

            return;
        }

        $first = $prefix[0];
        if (!isset($this->prefixesPsr0[$first][$prefix])) {
            $this->prefixesPsr0[$first][$prefix] = (array) $paths;

            return;
        }
        if ($prepend) {
            $this->prefixesPsr0[$first][$prefix] = array_merge(
                (array) $paths,
                $this->prefixesPsr0[$first][$prefix]
            );
        } else {
            $this->prefixesPsr0[$first][$prefix] = array_merge(
                $this->prefixesPsr0[$first][$prefix],
                (array) $paths
            );
        }
    }

    /**
     * Registers a set of PSR-4 directories for a given namespace, either
     * appending or prepending to the ones previously set for this namespace.
     *
     * @param string       $prefix  The prefix/namespace, with trailing '\\'
     * @param array|string $paths   The PSR-4 base directories
     * @param bool         $prepend Whether to prepend the directories
     *
     * @throws \InvalidArgumentException
     */
    public function addPsr4($prefix, $paths, $prepend = false)
    {
        if (!$prefix) {
            // Register directories for the root namespace.
            if ($prepend) {
                $this->fallbackDirsPsr4 = array_merge(
                    (array) $paths,
                    $this->fallbackDirsPsr4
                );
            } else {
                $this->fallbackDirsPsr4 = array_merge(
                    $this->fallbackDirsPsr4,
                    (array) $paths
                );
            }
        } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
            // Register directories for a new namespace.
            $length = strlen($prefix);
            if ('\\' !== $prefix[$length - 1]) {
                throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
            }
            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
            $this->prefixDirsPsr4[$prefix] = (array) $paths;
        } elseif ($prepend) {
            // Prepend directories for an already registered namespace.
            $this->prefixDirsPsr4[$prefix] = array_merge(
                (array) $paths,
                $this->prefixDirsPsr4[$prefix]
            );
        } else {
            // Append directories for an already registered namespace.
            $this->prefixDirsPsr4[$prefix] = array_merge(
                $this->prefixDirsPsr4[$prefix],
                (array) $paths
            );
        }
    }

    /**
     * Registers a set of PSR-0 directories for a given prefix,
     * replacing any others previously set for this prefix.
     *
     * @param string       $prefix The prefix
     * @param array|string $paths  The PSR-0 base directories
     */
    public function set($prefix, $paths)
    {
        if (!$prefix) {
            $this->fallbackDirsPsr0 = (array) $paths;
        } else {
            $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
        }
    }

    /**
     * Registers a set of PSR-4 directories for a given namespace,
     * replacing any others previously set for this namespace.
     *
     * @param string       $prefix The prefix/namespace, with trailing '\\'
     * @param array|string $paths  The PSR-4 base directories
     *
     * @throws \InvalidArgumentException
     */
    public function setPsr4($prefix, $paths)
    {
        if (!$prefix) {
            $this->fallbackDirsPsr4 = (array) $paths;
        } else {
            $length = strlen($prefix);
            if ('\\' !== $prefix[$length - 1]) {
                throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
            }
            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
            $this->prefixDirsPsr4[$prefix] = (array) $paths;
        }
    }

    /**
     * Turns on searching the include path for class files.
     *
     * @param bool $useIncludePath
     */
    public function setUseIncludePath($useIncludePath)
    {
        $this->useIncludePath = $useIncludePath;
    }

    /**
     * Can be used to check if the autoloader uses the include path to check
     * for classes.
     *
     * @return bool
     */
    public function getUseIncludePath()
    {
        return $this->useIncludePath;
    }

    /**
     * Turns off searching the prefix and fallback directories for classes
     * that have not been registered with the class map.
     *
     * @param bool $classMapAuthoritative
     */
    public function setClassMapAuthoritative($classMapAuthoritative)
    {
        $this->classMapAuthoritative = $classMapAuthoritative;
    }

    /**
     * Should class lookup fail if not found in the current class map?
     *
     * @return bool
     */
    public function isClassMapAuthoritative()
    {
        return $this->classMapAuthoritative;
    }

    /**
     * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
     *
     * @param string|null $apcuPrefix
     */
    public function setApcuPrefix($apcuPrefix)
    {
        $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
    }

    /**
     * The APCu prefix in use, or null if APCu caching is not enabled.
     *
     * @return string|null
     */
    public function getApcuPrefix()
    {
        return $this->apcuPrefix;
    }

    /**
     * Registers this instance as an autoloader.
     *
     * @param bool $prepend Whether to prepend the autoloader or not
     */
    public function register($prepend = false)
    {
        spl_autoload_register(array($this, 'loadClass'), true, $prepend);
    }

    /**
     * Unregisters this instance as an autoloader.
     */
    public function unregister()
    {
        spl_autoload_unregister(array($this, 'loadClass'));
    }

    /**
     * Loads the given class or interface.
     *
     * @param  string    $class The name of the class
     * @return bool|null True if loaded, null otherwise
     */
    public function loadClass($class)
    {
        if ($file = $this->findFile($class)) {
            includeFile($file);

            return true;
        }
    }

    /**
     * Finds the path to the file where the class is defined.
     *
     * @param string $class The name of the class
     *
     * @return string|false The path if found, false otherwise
     */
    public function findFile($class)
    {
        // class map lookup
        if (isset($this->classMap[$class])) {
            return $this->classMap[$class];
        }
        if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
            return false;
        }
        if (null !== $this->apcuPrefix) {
            $file = apcu_fetch($this->apcuPrefix.$class, $hit);
            if ($hit) {
                return $file;
            }
        }

        $file = $this->findFileWithExtension($class, '.php');

        // Search for Hack files if we are running on HHVM
        if (false === $file && defined('HHVM_VERSION')) {
            $file = $this->findFileWithExtension($class, '.hh');
        }

        if (null !== $this->apcuPrefix) {
            apcu_add($this->apcuPrefix.$class, $file);
        }

        if (false === $file) {
            // Remember that this class does not exist.
            $this->missingClasses[$class] = true;
        }

        return $file;
    }

    private function findFileWithExtension($class, $ext)
    {
        // PSR-4 lookup
        $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;

        $first = $class[0];
        if (isset($this->prefixLengthsPsr4[$first])) {
            $subPath = $class;
            while (false !== $lastPos = strrpos($subPath, '\\')) {
                $subPath = substr($subPath, 0, $lastPos);
                $search = $subPath.'\\';
                if (isset($this->prefixDirsPsr4[$search])) {
                    $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
                    foreach ($this->prefixDirsPsr4[$search] as $dir) {
                        if (file_exists($file = $dir . $pathEnd)) {
                            return $file;
                        }
                    }
                }
            }
        }

        // PSR-4 fallback dirs
        foreach ($this->fallbackDirsPsr4 as $dir) {
            if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
                return $file;
            }
        }

        // PSR-0 lookup
        if (false !== $pos = strrpos($class, '\\')) {
            // namespaced class name
            $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
                . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
        } else {
            // PEAR-like class name
            $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
        }

        if (isset($this->prefixesPsr0[$first])) {
            foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
                if (0 === strpos($class, $prefix)) {
                    foreach ($dirs as $dir) {
                        if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
                            return $file;
                        }
                    }
                }
            }
        }

        // PSR-0 fallback dirs
        foreach ($this->fallbackDirsPsr0 as $dir) {
            if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
                return $file;
            }
        }

        // PSR-0 include paths.
        if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
            return $file;
        }

        return false;
    }
}

/**
 * Scope isolated include.
 *
 * Prevents access to $this/self from included files.
 */
function includeFile($file)
{
    include $file;
}

autoload_static.php

autoload_static.php 文件内容:

<?php

// autoload_static.php @generated by Composer

namespace Composer\Autoload;

class ComposerStaticInit82c3996fbc74c498b11153bcc8cd8e49
{
    public static $files = array (
        'e8aa6e4b5a1db2f56ae794f1505391a8' => __DIR__ . '/..' . '/amphp/amp/lib/functions.php',
        '2cffec82183ee1cea088009cef9a6fc3' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
    );

    public static $prefixLengthsPsr4 = array (
        'y' => 
        array (
            'yii\\composer\\' => 13,
            'yii\\' => 4,
        ),
        'p' => 
        array (
            'peachpear\\pearLeaf\\' => 19,
        ),
        'c' => 
        array (
            'cebe\\markdown\\' => 14,
        ),
        'P' => 
        array (
            'Psr\\Log\\' => 8,
        ),
        'A' => 
        array (
            'Amp\\' => 4,
        ),
    );

    public static $prefixDirsPsr4 = array (
        'yii\\composer\\' => 
        array (
            0 => __DIR__ . '/..' . '/yiisoft/yii2-composer',
        ),
        'yii\\' => 
        array (
            0 => __DIR__ . '/..' . '/yiisoft/yii2',
        ),
        'peachpear\\pearLeaf\\' => 
        array (
            0 => __DIR__ . '/..' . '/peachpear/pear-leaf/src/pearLeaf',
        ),
        'cebe\\markdown\\' => 
        array (
            0 => __DIR__ . '/..' . '/cebe/markdown',
        ),
        'Psr\\Log\\' => 
        array (
            0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
        ),
        'Amp\\' => 
        array (
            0 => __DIR__ . '/..' . '/amphp/amp/lib',
        ),
    );

    public static $prefixesPsr0 = array (
        'K' => 
        array (
            'Kafka\\' => 
            array (
                0 => __DIR__ . '/..' . '/nmred/kafka-php/src',
            ),
        ),
        'H' => 
        array (
            'HTMLPurifier' => 
            array (
                0 => __DIR__ . '/..' . '/ezyang/htmlpurifier/library',
            ),
        ),
    );

    public static function getInitializer(ClassLoader $loader)
    {
        return \Closure::bind(function () use ($loader) {
            $loader->prefixLengthsPsr4 = ComposerStaticInit82c3996fbc74c498b11153bcc8cd8e49::$prefixLengthsPsr4;
            $loader->prefixDirsPsr4 = ComposerStaticInit82c3996fbc74c498b11153bcc8cd8e49::$prefixDirsPsr4;
            $loader->prefixesPsr0 = ComposerStaticInit82c3996fbc74c498b11153bcc8cd8e49::$prefixesPsr0;

        }, null, ClassLoader::class);
    }
}

autoload_files.php

autoload_files.php 文件内容:

<?php

// autoload_files.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'e8aa6e4b5a1db2f56ae794f1505391a8' => $vendorDir . '/amphp/amp/lib/functions.php',
    '2cffec82183ee1cea088009cef9a6fc3' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
);

autoload_classmap.php

autoload_classmap.php 文件内容:

<?php

// autoload_classmap.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
    'Callback' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php',
    'DOMDocumentWrapper' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php',
    'DOMEvent' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php',
);

autoload_namespaces.php

autoload_namespaces.php 文件内容:

<?php

// autoload_namespaces.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'Kafka\\' => array($vendorDir . '/nmred/kafka-php/src'),
    'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'),
);

autoload_psr4.php

autoload_psr4.php 文件内容:

<?php

// autoload_psr4.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'yii\\composer\\' => array($vendorDir . '/yiisoft/yii2-composer'),
    'yii\\' => array($vendorDir . '/yiisoft/yii2'),
    'peachpear\\pearLeaf\\' => array($vendorDir . '/peachpear/pear-leaf/src/pearLeaf'),
    'cebe\\markdown\\' => array($vendorDir . '/cebe/markdown'),
    'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
    'Amp\\' => array($vendorDir . '/amphp/amp/lib'),
);

install.json

install.json 文件内容:

[
    {
        "name": "amphp/amp",
        "version": "v1.2.2",
        "version_normalized": "1.2.2.0",
        "source": {
            "type": "git",
            "url": "https://github.com/amphp/amp.git",
            "reference": "4f2161da5f68f274f116985635aea63b5c0f54d2"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/amphp/amp/zipball/4f2161da5f68f274f116985635aea63b5c0f54d2",
            "reference": "4f2161da5f68f274f116985635aea63b5c0f54d2",
            "shasum": ""
        },
        "require": {
            "php": ">=5.5"
        },
        "require-dev": {
            "fabpot/php-cs-fixer": "~1.9",
            "phpunit/phpunit": "~4.8"
        },
        "time": "2016-05-12T12:54:59+00:00",
        "type": "library",
        "extra": {
            "branch-alias": {
                "dev-master": "1.0.x-dev"
            }
        },
        "installation-source": "dist",
        "autoload": {
            "psr-4": {
                "Amp\\": "lib/"
            },
            "files": [
                "lib/functions.php"
            ]
        },
        "notification-url": "https://packagist.org/downloads/",
        "license": [
            "MIT"
        ],
        "authors": [
            {
                "name": "Daniel Lowrey",
                "email": "rdlowrey@php.net",
                "role": "Creator / Lead Developer"
            }
        ],
        "description": "A non-blocking concurrency framework for PHP applications",
        "homepage": "https://github.com/amphp/amp",
        "keywords": [
            "async",
            "concurrency",
            "event",
            "non-blocking",
            "promise"
        ]
    },
    {
        "name": "bower-asset/inputmask",
        "version": "3.3.11",
        "version_normalized": "3.3.11.0",
        "source": {
            "type": "git",
            "url": "https://github.com/RobinHerbots/Inputmask.git",
            "reference": "5e670ad62f50c738388d4dcec78d2888505ad77b"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/RobinHerbots/Inputmask/zipball/5e670ad62f50c738388d4dcec78d2888505ad77b",
            "reference": "5e670ad62f50c738388d4dcec78d2888505ad77b",
            "shasum": ""
        },
        "require": {
            "bower-asset/jquery": ">=1.7"
        },
        "time": "2017-11-21T11:46:23+00:00",
        "type": "bower-asset-library",
        "extra": {
            "bower-asset-main": [
                "./dist/inputmask/inputmask.js",
                "./dist/inputmask/inputmask.extensions.js",
                "./dist/inputmask/inputmask.date.extensions.js",
                "./dist/inputmask/inputmask.numeric.extensions.js",
                "./dist/inputmask/inputmask.phone.extensions.js",
                "./dist/inputmask/jquery.inputmask.js",
                "./dist/inputmask/global/document.js",
                "./dist/inputmask/global/window.js",
                "./dist/inputmask/phone-codes/phone.js",
                "./dist/inputmask/phone-codes/phone-be.js",
                "./dist/inputmask/phone-codes/phone-nl.js",
                "./dist/inputmask/phone-codes/phone-ru.js",
                "./dist/inputmask/phone-codes/phone-uk.js",
                "./dist/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.js",
                "./dist/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.js",
                "./dist/inputmask/dependencyLibs/inputmask.dependencyLib.js",
                "./dist/inputmask/bindings/inputmask.binding.js"
            ],
            "bower-asset-ignore": [
                "**/*",
                "!dist/*",
                "!dist/inputmask/*",
                "!dist/min/*",
                "!dist/min/inputmask/*"
            ]
        },
        "installation-source": "dist",
        "license": [
            "http://opensource.org/licenses/mit-license.php"
        ],
        "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
        "keywords": [
            "form",
            "input",
            "inputmask",
            "jquery",
            "mask",
            "plugins"
        ]
    },
    {
        "name": "bower-asset/jquery",
        "version": "3.2.1",
        "version_normalized": "3.2.1.0",
        "source": {
            "type": "git",
            "url": "https://github.com/jquery/jquery-dist.git",
            "reference": "77d2a51d0520d2ee44173afdf4e40a9201f5964e"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/jquery/jquery-dist/zipball/77d2a51d0520d2ee44173afdf4e40a9201f5964e",
            "reference": "77d2a51d0520d2ee44173afdf4e40a9201f5964e",
            "shasum": ""
        },
        "time": "2017-03-20T19:02:00+00:00",
        "type": "bower-asset-library",
        "extra": {
            "bower-asset-main": "dist/jquery.js",
            "bower-asset-ignore": [
                "package.json"
            ]
        },
        "installation-source": "dist",
        "license": [
            "MIT"
        ],
        "keywords": [
            "browser",
            "javascript",
            "jquery",
            "library"
        ]
    },
    {
        "name": "bower-asset/punycode",
        "version": "v1.3.2",
        "version_normalized": "1.3.2.0",
        "source": {
            "type": "git",
            "url": "https://github.com/bestiejs/punycode.js.git",
            "reference": "38c8d3131a82567bfef18da09f7f4db68c84f8a3"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/bestiejs/punycode.js/zipball/38c8d3131a82567bfef18da09f7f4db68c84f8a3",
            "reference": "38c8d3131a82567bfef18da09f7f4db68c84f8a3",
            "shasum": ""
        },
        "time": "2014-10-22T12:02:42+00:00",
        "type": "bower-asset-library",
        "extra": {
            "bower-asset-main": "punycode.js",
            "bower-asset-ignore": [
                "coverage",
                "tests",
                ".*",
                "component.json",
                "Gruntfile.js",
                "node_modules",
                "package.json"
            ]
        },
        "installation-source": "dist"
    },
    {
        "name": "bower-asset/yii2-pjax",
        "version": "2.0.7.1",
        "version_normalized": "2.0.7.1",
        "source": {
            "type": "git",
            "url": "https://github.com/yiisoft/jquery-pjax.git",
            "reference": "aef7b953107264f00234902a3880eb50dafc48be"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/yiisoft/jquery-pjax/zipball/aef7b953107264f00234902a3880eb50dafc48be",
            "reference": "aef7b953107264f00234902a3880eb50dafc48be",
            "shasum": ""
        },
        "require": {
            "bower-asset/jquery": ">=1.8"
        },
        "time": "2017-10-12T10:11:14+00:00",
        "type": "bower-asset-library",
        "extra": {
            "bower-asset-main": "./jquery.pjax.js",
            "bower-asset-ignore": [
                ".travis.yml",
                "Gemfile",
                "Gemfile.lock",
                "CONTRIBUTING.md",
                "vendor/",
                "script/",
                "test/"
            ]
        },
        "installation-source": "dist",
        "license": [
            "MIT"
        ]
    },
    {
        "name": "cebe/markdown",
        "version": "1.1.2",
        "version_normalized": "1.1.2.0",
        "source": {
            "type": "git",
            "url": "https://github.com/cebe/markdown.git",
            "reference": "25b28bae8a6f185b5030673af77b32e1163d5c6e"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/cebe/markdown/zipball/25b28bae8a6f185b5030673af77b32e1163d5c6e",
            "reference": "25b28bae8a6f185b5030673af77b32e1163d5c6e",
            "shasum": ""
        },
        "require": {
            "lib-pcre": "*",
            "php": ">=5.4.0"
        },
        "require-dev": {
            "cebe/indent": "*",
            "facebook/xhprof": "*@dev",
            "phpunit/phpunit": "4.1.*"
        },
        "time": "2017-07-16T21:13:23+00:00",
        "bin": [
            "bin/markdown"
        ],
        "type": "library",
        "extra": {
            "branch-alias": {
                "dev-master": "1.1.x-dev"
            }
        },
        "installation-source": "dist",
        "autoload": {
            "psr-4": {
                "cebe\\markdown\\": ""
            }
        },
        "notification-url": "https://packagist.org/downloads/",
        "license": [
            "MIT"
        ],
        "authors": [
            {
                "name": "Carsten Brandt",
                "email": "mail@cebe.cc",
                "homepage": "http://cebe.cc/",
                "role": "Creator"
            }
        ],
        "description": "A super fast, highly extensible markdown parser for PHP",
        "homepage": "https://github.com/cebe/markdown#readme",
        "keywords": [
            "extensible",
            "fast",
            "gfm",
            "markdown",
            "markdown-extra"
        ]
    },
    {
        "name": "ezyang/htmlpurifier",
        "version": "v4.10.0",
        "version_normalized": "4.10.0.0",
        "source": {
            "type": "git",
            "url": "https://github.com/ezyang/htmlpurifier.git",
            "reference": "d85d39da4576a6934b72480be6978fb10c860021"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/d85d39da4576a6934b72480be6978fb10c860021",
            "reference": "d85d39da4576a6934b72480be6978fb10c860021",
            "shasum": ""
        },
        "require": {
            "php": ">=5.2"
        },
        "require-dev": {
            "simpletest/simpletest": "^1.1"
        },
        "time": "2018-02-23T01:58:20+00:00",
        "type": "library",
        "installation-source": "dist",
        "autoload": {
            "psr-0": {
                "HTMLPurifier": "library/"
            },
            "files": [
                "library/HTMLPurifier.composer.php"
            ]
        },
        "notification-url": "https://packagist.org/downloads/",
        "license": [
            "LGPL"
        ],
        "authors": [
            {
                "name": "Edward Z. Yang",
                "email": "admin@htmlpurifier.org",
                "homepage": "http://ezyang.com"
            }
        ],
        "description": "Standards compliant HTML filter written in PHP",
        "homepage": "http://htmlpurifier.org/",
        "keywords": [
            "html"
        ]
    },
    {
        "name": "nmred/kafka-php",
        "version": "v0.2.0.8",
        "version_normalized": "0.2.0.8",
        "source": {
            "type": "git",
            "url": "https://github.com/weiboad/kafka-php.git",
            "reference": "d5b395aeb9d069dce49fc1dceff0a6f45750d981"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/weiboad/kafka-php/zipball/d5b395aeb9d069dce49fc1dceff0a6f45750d981",
            "reference": "d5b395aeb9d069dce49fc1dceff0a6f45750d981",
            "shasum": ""
        },
        "require": {
            "amphp/amp": "v1.2.2",
            "php": ">=5.5",
            "psr/log": "1.0.2"
        },
        "require-dev": {
            "kmelia/monolog-stdout-handler": "1.2.1",
            "monolog/monolog": "1.22.1",
            "phpunit/phpcov": "*",
            "phpunit/phpunit": "~4.0",
            "satooshi/php-coveralls": "dev-master"
        },
        "time": "2017-10-23T09:33:08+00:00",
        "type": "library",
        "installation-source": "dist",
        "autoload": {
            "psr-0": {
                "Kafka\\": "src/"
            }
        },
        "notification-url": "https://packagist.org/downloads/",
        "license": [
            "BSD-3-Clause"
        ],
        "description": "Kafka client for php",
        "homepage": "http://www.swanlinux.net",
        "keywords": [
            "client",
            "kafka"
        ]
    },
    {
        "name": "peachpear/pear-leaf",
        "version": "1.0.5",
        "version_normalized": "1.0.5.0",
        "source": {
            "type": "git",
            "url": "https://github.com/peachpear/pear-leaf.git",
            "reference": "bdac9f3faa0681bb8e8060d0ddfa97e6dffe5e88"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/peachpear/pear-leaf/zipball/bdac9f3faa0681bb8e8060d0ddfa97e6dffe5e88",
            "reference": "bdac9f3faa0681bb8e8060d0ddfa97e6dffe5e88",
            "shasum": ""
        },
        "time": "2018-12-21T10:15:17+00:00",
        "type": "library",
        "installation-source": "dist",
        "autoload": {
            "psr-4": {
                "peachpear\\pearLeaf\\": "src/pearLeaf"
            }
        },
        "notification-url": "https://packagist.org/downloads/",
        "license": [
            "MPL-2.0"
        ],
        "authors": [
            {
                "name": "baiyang",
                "email": "zhuyingu@126.com"
            }
        ],
        "description": "project's setting leaf on linux",
        "keywords": [
            "PEAR",
            "leaf",
            "peachpear"
        ]
    },
    {
        "name": "psr/log",
        "version": "1.0.2",
        "version_normalized": "1.0.2.0",
        "source": {
            "type": "git",
            "url": "https://github.com/php-fig/log.git",
            "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
            "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
            "shasum": ""
        },
        "require": {
            "php": ">=5.3.0"
        },
        "time": "2016-10-10T12:19:37+00:00",
        "type": "library",
        "extra": {
            "branch-alias": {
                "dev-master": "1.0.x-dev"
            }
        },
        "installation-source": "dist",
        "autoload": {
            "psr-4": {
                "Psr\\Log\\": "Psr/Log/"
            }
        },
        "notification-url": "https://packagist.org/downloads/",
        "license": [
            "MIT"
        ],
        "authors": [
            {
                "name": "PHP-FIG",
                "homepage": "http://www.php-fig.org/"
            }
        ],
        "description": "Common interface for logging libraries",
        "homepage": "https://github.com/php-fig/log",
        "keywords": [
            "log",
            "psr",
            "psr-3"
        ]
    },
    {
        "name": "yiisoft/yii2",
        "version": "2.0.15.1",
        "version_normalized": "2.0.15.1",
        "source": {
            "type": "git",
            "url": "https://github.com/yiisoft/yii2-framework.git",
            "reference": "ed3a9e1c4abe206e1c3ce48a6b3624119b79850d"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/ed3a9e1c4abe206e1c3ce48a6b3624119b79850d",
            "reference": "ed3a9e1c4abe206e1c3ce48a6b3624119b79850d",
            "shasum": ""
        },
        "require": {
            "bower-asset/inputmask": "~3.2.2 | ~3.3.5",
            "bower-asset/jquery": "3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable",
            "bower-asset/punycode": "1.3.*",
            "bower-asset/yii2-pjax": "~2.0.1",
            "cebe/markdown": "~1.0.0 | ~1.1.0",
            "ext-ctype": "*",
            "ext-mbstring": "*",
            "ezyang/htmlpurifier": "~4.6",
            "lib-pcre": "*",
            "php": ">=5.4.0",
            "yiisoft/yii2-composer": "~2.0.4"
        },
        "time": "2018-03-21T18:36:53+00:00",
        "bin": [
            "yii"
        ],
        "type": "library",
        "extra": {
            "branch-alias": {
                "dev-master": "2.0.x-dev"
            }
        },
        "installation-source": "dist",
        "autoload": {
            "psr-4": {
                "yii\\": ""
            }
        },
        "notification-url": "https://packagist.org/downloads/",
        "license": [
            "BSD-3-Clause"
        ],
        "authors": [
            {
                "name": "Qiang Xue",
                "email": "qiang.xue@gmail.com",
                "homepage": "http://www.yiiframework.com/",
                "role": "Founder and project lead"
            },
            {
                "name": "Alexander Makarov",
                "email": "sam@rmcreative.ru",
                "homepage": "http://rmcreative.ru/",
                "role": "Core framework development"
            },
            {
                "name": "Maurizio Domba",
                "homepage": "http://mdomba.info/",
                "role": "Core framework development"
            },
            {
                "name": "Carsten Brandt",
                "email": "mail@cebe.cc",
                "homepage": "http://cebe.cc/",
                "role": "Core framework development"
            },
            {
                "name": "Timur Ruziev",
                "email": "resurtm@gmail.com",
                "homepage": "http://resurtm.com/",
                "role": "Core framework development"
            },
            {
                "name": "Paul Klimov",
                "email": "klimov.paul@gmail.com",
                "role": "Core framework development"
            },
            {
                "name": "Dmitry Naumenko",
                "email": "d.naumenko.a@gmail.com",
                "role": "Core framework development"
            },
            {
                "name": "Boudewijn Vahrmeijer",
                "email": "info@dynasource.eu",
                "homepage": "http://dynasource.eu",
                "role": "Core framework development"
            }
        ],
        "description": "Yii PHP Framework Version 2",
        "homepage": "http://www.yiiframework.com/",
        "keywords": [
            "framework",
            "yii2"
        ]
    },
    {
        "name": "yiisoft/yii2-composer",
        "version": "2.0.7",
        "version_normalized": "2.0.7.0",
        "source": {
            "type": "git",
            "url": "https://github.com/yiisoft/yii2-composer.git",
            "reference": "1439e78be1218c492e6cde251ed87d3f128b9534"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/yiisoft/yii2-composer/zipball/1439e78be1218c492e6cde251ed87d3f128b9534",
            "reference": "1439e78be1218c492e6cde251ed87d3f128b9534",
            "shasum": ""
        },
        "require": {
            "composer-plugin-api": "^1.0"
        },
        "require-dev": {
            "composer/composer": "^1.0"
        },
        "time": "2018-07-05T15:44:47+00:00",
        "type": "composer-plugin",
        "extra": {
            "class": "yii\\composer\\Plugin",
            "branch-alias": {
                "dev-master": "2.0.x-dev"
            }
        },
        "installation-source": "dist",
        "autoload": {
            "psr-4": {
                "yii\\composer\\": ""
            }
        },
        "notification-url": "https://packagist.org/downloads/",
        "license": [
            "BSD-3-Clause"
        ],
        "authors": [
            {
                "name": "Qiang Xue",
                "email": "qiang.xue@gmail.com"
            },
            {
                "name": "Carsten Brandt",
                "email": "mail@cebe.cc"
            }
        ],
        "description": "The composer plugin for Yii extension installer",
        "keywords": [
            "composer",
            "extension installer",
            "yii2"
        ]
    }
]

LICENSE

还有一个 LICENSE 文件,内容:


Copyright (c) Nils Adermann, Jordi Boggiano

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


参考资料


返回