助手内部的laravel调试显示我\ app \用户类未找到

发布于 2025-01-29 03:52:26 字数 992 浏览 2 评论 0原文

我正在尝试使用Xdebug在Laravel中进行第一次调试,并且当我设置断点并尝试在\ app \ user时尝试介绍一下,模型在调用它显示了我在下面附加的class class class classive mode n the Indy caste Inder clange Inder It saving me class图像:

在此处输入图像描述“

这是我的启动.json文件

{
"version":"0.2.0",
"configurations": [        
    {
        "name": "Listen for XDebug",
        "type": "php",
        "request": "launch",
        "port": 9000,
        "pathMappings": {
            "/opt/lampp/htdocs/investproTheme": "${workspaceRoot}",
            },
            // add this
            "ignore": [
                "**/vendor/**/*.php"
            ],
    },
    {
        "name": "Launch currently open script",
        "type": "php",
        "request": "launch",
        "program": "${file}",
        "cwd": "${fileDirname}",
        "port": 9001
    }

] }

I'm trying my first debug in Laravel using Xdebug and when I set the breakpoint and try to step over when \App\User model is calling it shows me class not found error which I attached in the below image:

enter image description here

this is my launch.json file below

{
"version":"0.2.0",
"configurations": [        
    {
        "name": "Listen for XDebug",
        "type": "php",
        "request": "launch",
        "port": 9000,
        "pathMappings": {
            "/opt/lampp/htdocs/investproTheme": "${workspaceRoot}",
            },
            // add this
            "ignore": [
                "**/vendor/**/*.php"
            ],
    },
    {
        "name": "Launch currently open script",
        "type": "php",
        "request": "launch",
        "program": "${file}",
        "cwd": "${fileDirname}",
        "port": 9001
    }

] }

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神经大条 2025-02-05 03:52:26

如果您使用的是Laravel 8或9 ,则错误地引用了用户模型,因此请尝试以下操作:

// In the first lines of your file
use \App\Models\User;

...

User::find($usr); // Call this way on line 310

-- OR --

\App\Models\User::find($usr);

还记得用建议的方式替换所有\ app \ user呼叫!

重新运行的作曲家自动加载程序

有时不跟踪某些拼写器,因此自动加载程序不会让它们工作,在这种情况下,请在控制台中尝试一下:

Composer dump-autoload

If you are using Laravel 8 or 9, you are wrongly referencing the User Model so try this:

// In the first lines of your file
use \App\Models\User;

...

User::find($usr); // Call this way on line 310

-- OR --

\App\Models\User::find($usr);

Also remember to replace all \App\User calls with suggested way!

Re-run composer auto-loader

Sometimes composer don't track some clases so the auto loader wont get them to work, in that case try this in the console:

composer dump-autoload

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文