Composer不加载类

时间:2016-11-25 23:18:43

标签: php composer-php

这是我的文件结构:

-src/
--classes
---helloKitty.php
--public
---index.php
--vendor
--composer.json

composer.json:

{
    "require": {
        "slim/slim": "^3.6"
    },

    "autoload": {
        "psr-4": {
            "Acme\\": "src/classes/"
        }
    }
}

的index.php

<?php
require_once "../vendor/autoload.php";
use Acme\helloKitty;

$hello = new helloKitty();
$hello->sayHello();

和helloKitty.php

namespace Acme;

class helloKitty
{
    public $hello = "Hello buddy";

    public function sayHello()
    {
        echo $this->hello;
    }
}

简单地说,它不会加载我的课程。这是我第一次与作曲家合作,但根据文档,一切都很好,我不知道出了什么问题。

这是我的错误:

  

致命错误:未捕获错误:未找到类'Acme \ helloKitty'   C:\ nginx \ html \ src \ public \ index.php:6堆栈跟踪:#0 {main}抛出   第6行的C:\ nginx \ html \ src \ public \ index.php

0 个答案:

没有答案
相关问题