Babaev
Babaev

Reputation: 253

How to specify a path in routing Laravel?

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

Upvotes: 1

Views: 470

Answers (2)

Rashedul Islam Sagor
Rashedul Islam Sagor

Reputation: 2069

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

Upvotes: 0

Alexey Mezenin
Alexey Mezenin

Reputation: 163968

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.

Upvotes: 1

Related Questions