douren7179 2016-02-16 12:42
浏览 69

Laravel Contract提供500错误

I've made a Contract interface and an Eloquent Repository for my application but I'm getting a 500 error when I try to use it.

I have a feeling it has something to do with the way it is registered. To do this with a service provider which has the following register method:

/**
* Register service provider bindings
*/
public function registerBindings() {
    $this->app->bind(
        \App\Repositories\Backend\EventContract::class,
        \App\Repositories\Backend\EloquentEventRepository::class
    );
}

I then use the contract as follows in my controller:

class EventController extends Controller {

/**
 * @var EventContract
 */
protected $events;

/**
 * EventController constructor.
 * @param EventContract $events
 */
public function __construct(EventContract $events)
{
    $this->events = $events;
}

/**
 * Display a listing of the resource.
 *
 * @return \Illuminate\Http\Response
 */
public function index()
{

    return view('backend.events.index')
                ->withEvents($this->events->getEventsPaginated(25, 1));

When I load the page with the 500 error there's no entry in the Laravel logs or the Nginx logs (I use Homestead with Vagrant).

Any idea? Thanks in advance

EDIT: Found some logs!

2016/02/17 09:47:52 [error] 1868#0: *331 FastCGI sent in stderr: "inate\Container\Container->make() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:674
PHP message: PHP 478. Illuminate\Container\Container->build() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:633
PHP message: PHP 479. Illuminate\Container\Container->getDependencies() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:779
PHP message: PHP 480. Illuminate\Container\Container->resolveClass() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:808
PHP message: PHP 481. Illuminate\Foundation\Application->make() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:853
PHP message: PHP 482. Illuminate\Container\Container->make() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:674
PHP message: PHP 483. Illuminate\Container\Container->build() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:633
PHP message: PHP 484. Illuminate\Container\Container->Illuminate\Container\{closure}() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:735
PHP message: PHP 485. Illuminate\Foundation\Application->make() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:230
PHP message: PHP 486. Illuminate\Container\Container->make() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:674
PHP message: PHP 487. Illuminate\Container\Container->build() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:633
PHP message: PHP 488. Illuminate\Container\Container->getDependencies() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:779
PHP message: PHP 489. Illuminate\Container\Container->resolveClass() /home
  • 写回答

1条回答 默认 最新

  • dongyou4411 2016-02-16 16:43
    关注

    May be stupid pointers, but no harm checking:

    1. Double check the namespace in respective files i.e. EventContract and EloquentEventRepository class files.

    2. Check if you have imported the namespace in the EventController if not using full path

    3. After registering service provider did you run composer dump-autoload -o

    Try using chrome devtools to see the response if debug is on

    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题