Php Laravel:更改异常处理程序类的位置

Php Laravel:更改异常处理程序类的位置,php,twitter-bootstrap,api,laravel,domain-driven-design,Php,Twitter Bootstrap,Api,Laravel,Domain Driven Design,我们正在重新构造应用程序的文件夹布局,使其更符合DDD域驱动程序的设计思想 e、 g 尽管我们遇到的一个问题是重新定位/Exceptions/Handler.php类。我们的视图将其重命名为ExceptionHandler,并将其放置在/app目录的根目录中 我们得到 PHP致命错误:未捕获的ReflectionException:类 App\Exceptions\Handler不存在 重新定位后出现错误 我假设Laravel很难依赖于该文件位于该确切位置,对吗?您还必须更新服务容器中该文件的绑

我们正在重新构造应用程序的文件夹布局,使其更符合
DDD
域驱动程序的设计思想

e、 g

尽管我们遇到的一个问题是重新定位
/Exceptions/Handler.php
类。我们的视图将其重命名为
ExceptionHandler
,并将其放置在
/app
目录的根目录中

我们得到

PHP致命错误:未捕获的ReflectionException:类 App\Exceptions\Handler不存在

重新定位后出现错误


我假设Laravel很难依赖于该文件位于该确切位置,对吗?

您还必须更新服务容器中该文件的绑定。 下面的例子来自Laravel5.2,但我猜所有的Laravel5+都应该是一样的

// bootstrap/app.php
$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class // Change this line with the new namespace
);

你是否
作曲家自动卸载了
?哈哈,我们所有人都遇到过这种事!:)
// bootstrap/app.php
$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class // Change this line with the new namespace
);