简体   繁体   English

Laravel:目标 [...] 在构建 [...] 时不可实例化

[英]Laravel: Target [...] is not instantiable when building [...]

I see there are a lot of questions on Stackoverflow like this, but they all seem to have different unrelated answers, so hear me out:我看到 Stackoverflow 上有很多这样的问题,但它们似乎都有不同的不相关答案,所以请听我说:
I'm updating an old Laravel app's file structure to that of the newest version (8.x) and I am getting this error when I visit the the / route: Error + Stack trace我正在将旧的 Laravel 应用程序的文件结构更新为最新版本 (8.x) 的文件结构,当我访问/路由时出现此错误:错误 + 堆栈跟踪

Illuminate\Contracts\Container\BindingResolutionException
Target [Illuminate\View\ViewFinderInterface] is not instantiable while building [App\Http\Controllers\HomeController, App\Lib\Services\Rendering\HomepageRenderer, Illuminate\View\Environment].

I'm not sure what this even means.我什至不确定这意味着什么。
Here is the code for the HomeController :这是HomeController的代码:

<?php

namespace App\Http\Controllers;
use App\Lib\Services\Mail\Mailer;
use App\Lib\Services\Validation\ContactValidator;
use App\Lib\Services\Rendering\HomepageRenderer;

use App;
use Illuminate\View\View;
use Input;
use Redirect;

use App\Http\Controllers\Controller;


class HomeController extends Controller
{
    /**
     * Validator instance.
     * 
     * @var Lib\Services\Validation\ContactValidator
     */
    private $validator;

    /**
     * Options instance.
     * 
     * @var Lib\Services\Options\Options
     */
    private $options;

    /**
     * Mailer instance.
     * 
     * @var Lib\Services\Mail\Mailer;
     */
    private $mailer;


    public function __construct(ContactValidator $validator, Mailer $mailer, HomepageRenderer $renderer)
    {
        $this->mailer = $mailer;
        $this->renderer = $renderer;
        $this->validator = $validator;
        $this->options = App::make('options');

        $this->beforeFilter('logged', array('only' => array('createreview')));
    }

    /**
     * Show homepage.
     * 
     * @return View
     */
    public function index()
    {   
        return $this->renderer->render('Home.Home')->withCleantitle("Newest Reviews");  
    }

    /**
     * Show contact us page.
     * 
     * @return View
     */
    public function contact()
    {
        return View::make('Main.Contact');
    }

    public function createreview()
    {
        return View::make('Reviews.Create')->withCleantitle("Post Your Review");
    }

    /**
     * Sends an email message from contact us form.
     * 
     * @return View
     */
    public function submitContact()
    {
        $input = Input::all();

        if ( ! $this->validator->with($input)->passes())
        {
            return Redirect::back()->withErrors($this->validator->errors())->withInput($input);
        }

        $this->mailer->sendContactUs($input);

        return Redirect::to('/')->withSuccess( trans('main.contact succes') );
    }
}

What does the error mean and what can I do to resolve it?该错误是什么意思,我该怎么做才能解决它?
Thanks.谢谢。

Wouldn't using view('Home.Home') be sufficient?使用view('Home.Home')还不够吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM