Php 错误类不存在
我得到的错误是Php 错误类不存在,php,laravel,eloquent,laravel-5,Php,Laravel,Eloquent,Laravel 5,我得到的错误是 ReflectionException in compiled.php line 1082: Class App\Repositories\Frontend\Lewp does not exist 下面是较长的错误消息 in compiled.php line 1082 at ReflectionParameter->getClass() in compiled.php line 1082 at Container->getDependencies(array(ob
ReflectionException in compiled.php line 1082:
Class App\Repositories\Frontend\Lewp does not exist
下面是较长的错误消息
in compiled.php line 1082
at ReflectionParameter->getClass() in compiled.php line 1082
at Container->getDependencies(array(object(ReflectionParameter)), array()) in compiled.php line 1074
at Container->build('App\Http\Controllers\Frontend\FrontendController', array()) in compiled.php line 1012
at Container->make('App\Http\Controllers\Frontend\FrontendController', array()) in compiled.php line 1550
at Application->make('App\Http\Controllers\Frontend\FrontendController') in compiled.php line 8791
at ControllerDispatcher->makeController('App\Http\Controllers\Frontend\FrontendController') in compiled.php line 8780
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\Frontend\FrontendController', 'lewp') in compiled.php line 7759
at Route->runWithCustomDispatcher(object(Request)) in compiled.php line 7730
at Route->run(object(Request)) in compiled.php line 7383
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9455
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9437
at Pipeline->then(object(Closure)) in compiled.php line 7384
at Router->runRouteWithinStack(object(Route), object(Request)) in compiled.php line 7372
at Router->dispatchToRoute(object(Request)) in compiled.php line 7357
at Router->dispatch(object(Request)) in compiled.php line 2066
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9455
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 2637
at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9447
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 12699
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9447
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 11348
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9447
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 12437
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9447
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 12376
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9447
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 2687
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9447
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9437
at Pipeline->then(object(Closure)) in compiled.php line 2013
at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 1999
at Kernel->handle(object(Request)) in index.php line 54
at require_once('C:\projects\lewp\public\index.php') in server.php line 21
我不能肯定我的一切都设置正确。我一直在努力正确地设置,并努力解决所有东西如何相互连接的问题
<?php namespace App\Http\Controllers\Frontend;
use App\Http\Controllers\Controller;
use App\Repositories\Frontend\Lewp as Lewp;
/**
* Class FrontendController
* @package App\Http\Controllers
*/
class FrontendController extends Controller {
protected $lewp;
function __construct(Lewp $lewp) {
$this->lewp = $lewp;
}
/**
* @return \Illuminate\View\View
*/
public function index()
{
return view('frontend.index');
}
/**
* @return \Illuminate\View\View
*/
public function macros()
{
return view('frontend.macros');
}
public function post()
{
return view('frontend.post');
}
public function exterior()
{
return view('frontend.exterior');
}
public function submit()
{
return view('frontend.submit');
}
public function self()
{
return view('frontend.self');
}
public function lewp($name)
{
if(strlen($name) == 0)
{
return view('frontend.index');
}
$lewp = $this->lewp->getLewpByName($name);
return view::make('frontend.lewp', array('lewp' => $lewp));
}
}
类Lewp修复中的:
namespace App\Repositories\Frontend;
如果名称空间正确且问题仍然存在
尝试在你的流浪者中运行$composer dump autoload
。您好,我更改了它,但仍然收到相同的错误。我更改的是命名空间应用程序;根据您的建议。您是否已将您的类包含在composer.json中?如果是,您是否运行了?composer dump autoload
<?php namespace App\Repositories\Frontend;
use App\Lewp;
use App\Exceptions\GeneralException;
/**
* Class EloquentUserRepository
* @package App\Repositories\Lewp
*/
class EloquentLewpRepository implements LewpContract {
public function __construct(Lewp $lewpRepository)
{
$this->lewpRepository = $lewpRepository;
}
/**
* @param $id
* @return \Illuminate\Support\Collection|null|static
* @throws GeneralException
*/
public function findOrThrowException($id) {
$lewp = Lewp::find($id);
if (! is_null($lewp)) return $lewp;
throw new GeneralException('That lewp does not exist.');
}
/**
* @param $data
* @param bool $provider
* @return static
*/
public function create($data) {
$lewp = Lewp::create([
'name' => $data['name'],
'title' => $data['title'],
'text' => $data['text'],
'sidebar' => $data['sidebar'],
'submission_text' => $data['submission_text'],
'type' => $data['type'],
'content_options' => $data['content_options'],
'link_button_text' => $data['link_button_text'],
'text_button_text' => $data['text_button_text'],
'options' => $data['options'],
'comment_sort_method' => $data['comment_sort_method'],
'hide_comment_scores' => $data['hide_comment_scores'],
'header_mouseover-text' => $data['header_mouseover-text']
]);
return $lewp;
}
public function searchLewpsByName($term) {
$lewp = Lewp::where('name', 'LIKE', $term)->get();
return $lewp;
}
public function getLewpByName($lewpname) {
$lewp = Lewp::where('name', '=', $lewpname)->first();
return $lewp;
}
public function getLewpId($lewpname) {
$lewp = Lewp::select(array('id')->where('name', '=', $lewpname)->first();
return $lewp;
}
}
namespace App\Repositories\Frontend;