首页 文章

Php工匠不工作(laravel 5.1)

提问于
浏览
3

突然,当我输入 php artisan 或任何工匠命令时,我看到了这条消息

[ErrorException]试图获取非对象的属性

我尝试了以下内容

1- php artisan clear-compiled

2-删除 vendor 目录并使用 composer installcomposer update

3-克隆一个标准的Laravel应用程序并将我的文件 app dir和我的配置并使用 composer 命令,但步骤错误已更改为

[ErrorException]试图获取非对象的属性脚本php artisan clear-compiled处理post-install-cmd事件,返回错误[RuntimeException]错误输出:

有什么建议 ?

谢谢

2 回答

  • 1

    如果我理解得当,您在使用应用程序文件时会遇到此问题 . 这可能意味着您在构造函数中遇到了一些问题 - 您尝试运行函数并且对象未初始化 . 你不应该在构造函数中设置东西(例如在你的控制器上查找)或者你会得到一些“奇怪的”错误,你的工匠将无法正常工作

  • 2

    在我的应用程序导航后,我在我的 ServiceProviderClass boot() 方法中发现问题,特别是当注释一个方法根据子域名获取数据时 artisan 运行良好

    Laravel Doc提示这种方法

    This method is called after all other service providers have been registered, meaning you have access to all other services that have been registered by the framework

    更多阅读Laravel service provider

相关问题