自动加载作曲家可以找到类

发布于 2025-02-10 10:54:48 字数 585 浏览 1 评论 0原文

我正在尝试初学者课程PHP。我有一个关于与作曲家自动建立的问题。 class'app \ email'

我的目录结构

autoloading
    -app
        Email.php
        Person.php
    -src
    -composer.json
    -index.php

我有致命的错误:未被发现的错误:在index.php

require_once "vendor/autoload.php";

$email = new app\Email();
$person = new app\Person();

和composer.json中的

"autoload": {
    "psr-4": {
        "Dung6\\Autoloading\\": "src/",
        "App\\": "app/"
        
    }
},

“ app \\”中的 :“ app/”我在每次更改时都尝试。但是什么都没有用。有人可以为我检查。谢谢你!

I was try on a beginners course php. I had a issue about autouploading with composer. I had Fatal error: Uncaught Error: Class 'app\Email' not found in...

My directory structure looks like this

autoloading
    -app
        Email.php
        Person.php
    -src
    -composer.json
    -index.php

in index.php

require_once "vendor/autoload.php";

$email = new app\Email();
$person = new app\Person();

And in composer.json had

"autoload": {
    "psr-4": {
        "Dung6\\Autoloading\\": "src/",
        "App\\": "app/"
        
    }
},

in "App\\": "app/" I was try ./app, /app/,... and I was composer dump-autoload every time I change. But nothing work at all. Some one can check it for me. Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文