【问题标题】:Extending the custom class in laravel 4在 laravel 4 中扩展自定义类
【发布时间】:2014-11-27 01:00:09
【问题描述】:

我在模型文件夹中有一个名为“CustomItem.php”的模型类

class CustomItem extends Neoquent {
   ...
}

而且我没有在 CustomItem.php 中使用命名空间。我在同一个文件夹中有 Neoquent.php 与代码

class Neoquent extends Eloquent {
   ...
}

我已经在 composer.json 中自动加载了类文件夹

"autoload": {
        "classmap": [
            "app/controllers",
            "app/models"
        ]
    },

我已经在 global.php 中注册了额外的类

ClassLoader::addDirectories(array(
    app_path().'/controllers',
    app_path().'/models'
));

但我收到以下错误

Symfony\Component\Debug\Exception\FatalErrorException (E_ERROR) 未找到“Neoquent”类

【问题讨论】:

  • 你重新运行install了吗?来自作曲家文档:“添加自动加载字段后,您必须重新运行安装以重新生成 vendor/autoload.php 文件。”
  • 是的,我做到了,但还是一样

标签: php symfony laravel-4


【解决方案1】:

尝试运行composer dump-autoload - 如上所述,需要重新创建 autoload.php

【讨论】:

  • 我运行了命令 composer dump-autoload 和 composer install 但仍然没有运气:(
猜你喜欢
  • 2023-03-11
  • 1970-01-01
  • 2013-06-08
  • 2012-12-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-13
  • 2013-05-29
相关资源
最近更新 更多