Skip to content

Instantly share code, notes, and snippets.

@patrickmaciel
Created January 25, 2013 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save patrickmaciel/4630347 to your computer and use it in GitHub Desktop.
Save patrickmaciel/4630347 to your computer and use it in GitHub Desktop.
Route with namespace in Laravel 4 - ERROR: Whoops, looks like something went wrong. FatalErrorException: Error: Class 'PatrickMaciel\Admin\BaseController' not found in /home/..../app/controllers/admin/ProjectsController.php line 3
<?php namespace PatrickMaciel;
class BaseController extends Controller {
/**
* Setup the layout used by the controller.
*
* @return void
*/
protected function setupLayout()
{
if ( ! is_null($this->layout))
{
$this->layout = View::make($this->layout);
}
}
}
<?php namespace PatrickMaciel;
class HomeController extends BaseController {
/*
|--------------------------------------------------------------------------
| Default Home Controller
|--------------------------------------------------------------------------
|
| You may wish to use controllers instead of, or in addition to, Closure
| based routes. That's great! Here is an example controller method to
| get you started. To route to this controller, just add the route:
|
| Route::get('/', 'HomeController@showWelcome');
|
*/
public function index()
{
return View::make('home.index');
}
}
<?php namespace PatrickMaciel\Admin;
class ProjectsController extends BaseController {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
echo 'oi'; exit;
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
}
/**
* Display the specified resource.
*
* @return Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @return Response
*/
public function update($id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @return Response
*/
public function destroy($id)
{
//
}
}
<?php
Route::get('/', 'HomeController@index');
Route::get('admin/projects', 'PatrickMaciel\\Admin\\ProjectsController@index');
// Route::resource('admin/projects', 'admin.ProjectsController');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment