composer 自动加载

{
    "name": "test/demo",
    "description": "gaoxing test",
    "type": "project",
    "license": "1.0",
    "authors": [
        {
            "name": "John Smith",
            "email": "john@example.com"
        }
    ],
    "minimum-stability": "dev",
    "require": {
        "noahbuscher/macaw": "dev-master",
        "monolog/monolog": "1.25.2"
    },
    "autoload": {
     "classmap": [
            "database"
        ],
"psr-4": {
            "controllers\\" : "app/controllers/"
        },
        "files": [
            "app/helper.php"
        ]
    }
}

在files中加入的文件可实现单文件自动加载

必须执行composer dump-autoload,自动加载才生效,它会把,这个自动加载写入  自动加载的配置文件中.

posted @ 2020-01-15 17:11  没事就更  阅读(526)  评论(0编辑  收藏  举报