1

I have located contoller in directory dashboard, how to specify correct path in routing to this controller?

I have class by path:

Class App\Http\Controllers\Dashboard\PlaceController

But I get error that this class : does not exist

4
  • Can you show what you have in your routes file? Commented Sep 5, 2016 at 10:45
  • I have this: Route::resource('place', 'Dashboard\PlaceController'); Commented Sep 5, 2016 at 10:49
  • make sure you have this line in top of controller: namespace App\Http\Controllers\Dashboard; Commented Sep 5, 2016 at 10:50
  • I tried to set: namespace App\Http\Controllers\Dashboard; then I get: Class 'App\Http\Controllers\Dashboard\Controller' not found Commented Sep 5, 2016 at 10:51

2 Answers 2

1

Laravel uses PSR-4 namespaces, so you need to make sure controller is in correct namespace:

namespace App\Http\Controllers\Dashboard;

use App\Http\Controllers\Controller;

class PlaceController extends....

If namespace is correct, try to run composer dumpauto command.

Sign up to request clarification or add additional context in comments.

3 Comments

Yes, buy when I do: class OrderController extends Controller It search Controller.php file in Dashboard
Class 'App\Http\Controllers\Dashboard\Controller' not found in line extends Controller
Add use App\Http\Controllers\Controller; clause to the controller.
0

Here are a example :

Laravel 5.2 :

  1. create a directory on >> App >> Http >> Controllers >> Dashboard
  2. create a file >>App>>Http>>Controllers>>Dashboard>> PlaceController.php

PlaceController.php

<?php
namespace App\Http\Controllers\Dashboard;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Http\Requests;


class PlaceController extends Controller
{
   // write your functions
}

command line

on command line : composer dump-autoload

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.