Home > Backend Development > PHP Tutorial > composer的autoload只能自动加载vendor目录下的文件吗?

composer的autoload只能自动加载vendor目录下的文件吗?

WBOY
Release: 2016-06-06 20:16:10
Original
1035 people have browsed it

composer.json这样的声明是只能加载composer.json所在目录vendor下的文件吗?

<code>"autoload":{
        "psr-4":{
          "components\\":"components/"
        }
    },</code>
Copy after login
Copy after login

如果components目录和文件composer.json在同一个目录下,好像不能加载。

回复内容:

composer.json这样的声明是只能加载composer.json所在目录vendor下的文件吗?

<code>"autoload":{
        "psr-4":{
          "components\\":"components/"
        }
    },</code>
Copy after login
Copy after login

如果components目录和文件composer.json在同一个目录下,好像不能加载。

<code>    "autoload": {
        "classmap": [
            "app/controllers" #自动加载composer.json同级目录下app/controllers的目录中的类文件
        ],
        "files": [
            "service" #自动加载composer.json同级目录service文件夹下的文件
        ] 
      }</code>
Copy after login

注意每次添加新文件后执行

<code>composer dump-autoload</code>
Copy after login
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