Laravel package Controller not found in route

laravel package development
laravel routes not working on live server
laravel 5.7 routes not working
laravel packages
laravel web php not working

I have a simple package and I want to use the controller. When I try to use it in routes I got

Class App\Http\Controllers\Tropicalista\Admin\Controllers\DashboardController 
does not exist

I have this in my /routes/web.php

    'namespace' => '\Tropicalista\Admin\Controllers', 
    'prefix'=> 'admin'], function() {

        Route::get('/', ['as' => 'admin.root', 'uses' => 'DashboardController@index']);


My controller:

namespace Tropicalista\Admin\Controllers;

use Illuminate\Http\Request;
use Analytics;
use Carbon\Carbon;
use Spatie\Analytics\Period;
use Illuminate\Support\Collection;
use Illuminate\Routing\Controller;

class DashboardController extends Controller

I think is a namespace problem. So how can I call the package controller?

By default, the RouteServiceProvider includes your route files within a namespace group, allowing you to register controller routes without specifying the full App\Http\Controllers namespace prefix. So, you only need to specify the portion of the namespace that comes after the base App\Http\Controllers namespace.

You need to remove namespace

Route::group(['prefix'=> 'admin'], function() {

    Route::get('/', ['as' => 'admin.root', 'uses' => '\Tropicalista\Admin\Controllers\DashboardController@index']);


Class not found in Controller - Package development, But when I try to add a controller and access the route, It gives me an error saying that the Controller was not found. Here is my folder structure (everything is ok,� For example, you could use Laravel Scout which is an official Laravel package, you can take a look at this tutorial here on how to install, setup and use Laravel scout with Algolia. However, in this tutorial here, we will focus on building a very simple search method without the need of installing additional packages.

Since it's a package, you need to register the routes in the package.

You can see an example of registering package controllers here:

$routeConfig = [
    'namespace' => 'Barryvdh\Debugbar\Controllers',
    'prefix' => $this->app['config']->get('debugbar.route_prefix'),
    'domain' => $this->app['config']->get('debugbar.route_domain'),
    'middleware' => [DebugbarEnabled::class],
$this->getRouter()->group($routeConfig, function($router) {
    $router->get('open', [
        'uses' => 'OpenHandlerController@handle',
        'as' => 'debugbar.openhandler',

Laravel package Routing not working, Hi guys I'm working on a Laravel Package and want to provide some Routes in this ServiceProvider { /** * This namespace is applied to the controller routes in � This method provides a convenient shortcut so that you do not have to define a full route or controller for performing a simple redirect: Route::redirect('/here', '/there'); By default, Route::redirect returns a 302 status code. You may customize the status code using the optional third parameter: Route::redirect('/here', '/there', 301);

In order to call package controller, change the namespace group of RouteServiceProvider from

protected $namespace = 'App\Http\Controllers';

to null/empty i.e.

protected $namespace = '';

Then, the route can be written as,

Route::get('homepage', 'Package\Namespace\Controllers\ControllerName@ActionName');

Further, if you want to write route for the default controller, use leading slash '/' before starting url.

Route::get('/homepage', 'App\Http\Controllers\ControllerName@ActionName');

Whether it is good practice or not but it solved the problem.

Route not working for package controller with auth middleware, Route not working for package controller with auth middleware. Posted 6 In the package's own routes/web.php : I am on Laravel version 6.9.0. Please also� The route parameters will also be passed to the method. {tip} Controllers are not required to extend a base class. However, you will not have access to convenience features such as the middleware, validate, and dispatch methods. Controllers & Namespaces. It is very important to note that we did not need to specify the full controller namespace

Laravel 5.3 package development: Class not found, Laravel 5.3 package development: Class not found following error: Class ' Pedroroccon\Boilerplate\Controller' not found in my file BoilerplateController.php line 8. And finally, this is my routes.php file, inside the src folder: //route not define Route::resource('', 'EmployersJobController'); Please sign in or create an account to participate in this conversation. The most concise screencasts for the working developer, updated daily.

Routes defined in routes/web.php not working anymore � Issue #755 , Below routes defined in Laravel's default routing file routes/web.php are not In newer versions of this package, routes are now written in a "route The namespace attribute is not working as it tries to search the controllers� no_prefix allows any prefix added to the routes in that controller be ignored for this particular route. @Post, @Options, @Put, @Patch, @Delete, @any. The @Post, @Options, @Put, @Patch, @Delete, and @Any annotations have the exact same syntax as the @Get annotation, except it will register a route for the respective HTTP verb, as opposed to the GET verb.

navigating from route to controller not working � Issue #217 , Environmental information in case of problems: MacOS mojave 10.14.4; laravel 5.5 lts; php7.3. 9. Laravel pedroroccon • 3 years ago. 287 2. Laravel Class not found in Controller - Package development But when I try to add a controller and access the route