Reflectionexception: Class Classname Does Not Exist - Laravel

ReflectionException: Class ClassName does not exist - Laravel

Perform a composer update, then composer dump-autoload.

If the above doesn't solve the problem, change the classmap in your composer.json file such that it contains the project-relative path to your php files:

"autoload-dev": {
"classmap": [
"tests/TestCase.php",
"database/seeds/UserTableSeeder.php" //include the file with its path here
]
}, /** ... */

and soon after, perform a composer dump-autoload, and it should work now like a breeze!

Edit by @JMSamudio

If composer dump-autoload is not found, just enable this option composer config -g -- disable-tls true.

Laravel ReflectionException: class does not exist

I solved it. They should update the code.
For anyone with the same issue:

They are publishing the cms-routes file with just the namespace Cms which is wrong. It has to be the full namespace App\Http\Controllers\Cms. So edit your cms-routes to look like this:

Route::group(['namespace' => 'App\Http\Controllers\Cms', 'middleware' => ['cms-language', 'cms-analytics']], function () {
Route::get('', 'PagesController@home');
Route::get('pages', 'PagesController@all');
Route::get('page/{url}', 'PagesController@show');
Route::get('p/{url}', 'PagesController@show');

Route::get('gallery', 'GalleryController@all');
Route::get('gallery/{tag}', 'GalleryController@show');

Route::get('blog', 'BlogController@all');
Route::get('blog/{url}', 'BlogController@show');
Route::get('blog/tags/{tag}', 'BlogController@tag');

Route::get('faqs', 'FaqController@all');

Route::get('events', 'EventsController@calendar');
Route::get('events/{month}', 'EventsController@calendar');
Route::get('events/all', 'EventsController@all');
Route::get('events/date/{date}', 'EventsController@date');
Route::get('events/event/{id}', 'EventsController@show');
});

ReflectionException - Class name does not exist in Laravel 5.0

You need to run

composer dump-autoload

to fix this error. What this does, among other things, is refreshes the list of classes available to your application.

In this case, while the class did exist in the right location, it was unavailable in your autoloaded class list, and thus returning a Not Found error.

Laravel 8: ReflectionException Function () does not exist

You should write your routes like this:

and change PurchaseController to PurchasesController

Route::get('/purchases', [PurchasesController::class, 'index']);
Route::post('/purchases', [PurchasesController::class, 'purchase']);

and

use App\Http\Controllers\PurchasesController;

Reflection Exception : Class ClassName doesn't exist

Well thanks to Jerodev and Jack. Since, both of them were write I decided to write myself a combined solution to this problem.

1st Solution:

In case of custom namespaces and custom classes I have to include the path to classname in Composer.json file in the following portion:

"autoload": {
"classmap": [
"database/seeds",
"database/factories",
"app/Bishwa/Transformers"

],
"psr-4": {
"App\\": "app/"
}

2nd Solution:

Changing NameSpace of my files to custom directory App\Bishwa .

Namespace of transformer.php and LessonTransformer.php now becomes:

namespace App\Bishwa\Transformers;

While using in LessonsController:

use App\Bishwa\Transformers\LessonTransformer;

Once again, big thanks to Jerodev and Jack. Its my silly mistake, that I couldn't figure that out.

Laravel ReflectionException (-1) Class country does not exist

Solved it by adding the below to the routeMiddleware in App\Http\Kernel.php

'country' => \App\Http\Middleware\CountryMiddleware::class,

And i have changed the below code in CountryMiddleware

if ($country === null) {
return redirect('/USA');
}

so that default location is usa and any users with incorrect or missing location will be redirected to usa

Laravel 5.3 Route::get() returns error Class [classname] does not exist

first run the command composer dump-autoload

If its not work, than follow those steps:

step-1: create route inside routes\web.php
Route::get('/', 'SiteController@index');

step-2: create a controller using cmd like php artisan make:controller SiteController

inside: app/Providers/RouteServiceProvider.php should be like this:

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';

/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//

parent::boot();
}

/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapWebRoutes();

$this->mapApiRoutes();

//
}

/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::group([
'middleware' => 'web',
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/web.php');
});
}

/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::group([
'middleware' => ['api', 'auth:api'],
'namespace' => $this->namespace,
'prefix' => 'api',
], function ($router) {
require base_path('routes/api.php');
});
}
}

Inside: app/Http/Controllers/SiteController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

class SiteController extends Controller
{
public function index() {
return view('pages.index');
}
}

Create view page inside the:
resources/views/pages/index.blade.php

Run server using cmd php artisan serve

Hope this help's you!

ReflectionException : Class PermissionsTableSeeder does not exist

This helped. Solution on the same issue from the package itself.



Related Topics



Leave a reply



Submit