Fatal Error Exception class app\http\controllers\controller not found - php

Fatal Error
Exception class app\http\controllers\controller not found
while I run the command php artisan route:list and other all commands are working correctly.
I have named my project as "Socialite" and give namespace to controller.php as "namespace Socialite\Http\Controllers;". I also auto-dumped my project.
there is no any syntax error in routes/web.php.
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/
Route::get('/', 'HomeController#index')->name('start');
Route::get('/signup','HomeController#getSignup')->name('auth.signup');
Route::post('/signup','HomeController#postSignup')->name('auth.signup');
Route::get('/signin','HomeController#getSignin')->name('auth.signin');
Route::post('/signin','HomeController#postSignin')->name('auth.signin');
Auth::routes();

You should use this command to rename an app:
php artisan app:name Socialite
Or change namespace of all classes your app uses manually, for example for Controller.php namespace will be:
namespace Socialite\Http\Controllers;

Related

LARAVEL SAIL: how to solve problem with poser in laravel sail

I started the project through laravel sail and I can't see the
view's index on localhost, when I enter the link I get the error:
target class [] does not exist.
and below that error message shows the following code, which corresponds to the index.php file:
<?php
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
/*
| Check If The Application Is Under Maintenance
|
| If the application is in maintenance / demo mode via the "down" command
| we will load this file so that any pre-rendered content can be shown
| instead of starting the framework, which could cause an exception.
*/
if (file_exists($maintenance =
__DIR__.'/../storage/framework/maintenance.php')) {
require $maintenance;
}
/*
| Register The Auto Loader
|
| Composer provides a convenient, automatically generated class loader for
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
*/
require __DIR__.'/../vendor/autoload.php';
/*
| Run The Application
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
$kernel = $app->make(Kernel::class);
$response = $kernel->handle(
$request = Request::capture()
)->send();
$kernel->terminate($request, $response);
The content that I put in the view index.blade.php should be
displayed, the route was declared, the controller exists and the
above error appears

Laravel 7.2.5 Unable to prepare route [api/user] for serialization. Uses Closure

I was facing the issue when I do php artisan optimize.
Below is my api.php
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
/* |-------------------------------------------------------------------------- | API Routes |-------------------------------------------------------------------------- | | Here is where you can register API routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | is assigned the "api" middleware group. Enjoy building your API! | */
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
I am confuse & don't know what I am missing.
Already tried following options
Delete all cache files
Also tried php artisan cache:clear
Composer update / composer dump-autoload
env file changes CACHE_DRIVER=file,SESSION_DRIVER=database
Thanks in advance .
If you check Laravel's optimize command:
/**
* Execute the console command.
*
* #return void
*/
public function handle()
{
$this->call('config:cache');
$this->call('route:cache');
$this->info('Files cached successfully!');
}
There is a line $this->call('route:cache');
This line is throwing the error.
Laravel is trying to cache the routes. It does not accept Closure while caching the route. That's why moving your code to a controller fixed the issue.

Laravel auth won't let me "get" from Database

So I've cloned my own laravel project, that works on my main machine, to my test pc and set it up as follows:
Installed XAMPP and set it up.
git clone project to the machine.
Installed composer on the machine.
executed the command composer install.
php artisan key:generate.
I installed Postgres and set up a DB
uncommented Postgres extensions in php.ini
Edited the .env file to connect to the DB
php artisan migrate:fresh.
php artisan db:seed. (New users)
Now when trying to log in, the page just refreshes. I found out that I'm able to read and write to the database when creating a new page that is not protected by the login.
So something with the whole auth situation must be wrong. Did I miss anything when setting the whole project up? Or where the commands executed in the wrong order?
Oh btw. The auth was made with php artisan make:auth
Here is part of my web.php. The whole thing is really big.
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController#index');
Route::get('/user', 'UsersController#index')->middleware(['auth.admin']);
Route::post('/user', 'UsersController#store')->middleware(['auth.admin']);
Route::get('/user/edit/{id}', 'UsersController#edit')->middleware(['auth.admin']);
Route::post('/user/update/{id}', 'UsersController#update')->middleware(['auth.admin']);
Route::get('/user/delete/{id}', 'UsersController#delete')->middleware(['auth.admin']);
Route::get('/usersearch', 'UsersController#search');
Route::get('/user/paginate/{id}', 'UsersController#paginate')->middleware(['auth.admin']);
Route::get('/order', 'OrderItemController#index');
Route::get('/order/delete/{id}', 'OrderItemController#delete');
Route::get('/order/edit/{id}', 'OrderItemController#edit');
Route::post('/order/update/{id}', 'OrderItemController#update');
Route::post('/order', 'OrderItemController#store');
Route::get('/ordersearch', 'OrderItemController#search');
Route::get('/order/paginate/{id}', 'OrderItemController#paginate');
Route::get('/customer/delete/{id}', 'CustomerController#delete');
Route::get('/customer/edit/{id}', 'CustomerController#edit');
Route::post('/customer/update/{id}', 'CustomerController#update');
Route::get('/customer', 'CustomerController#index');
Route::post('/customer', 'CustomerController#store');
Route::get('/customer/paginate/{id}', 'CustomerController#paginate');
Please check your current laravel version.
php artisan make:auth command is not longer available from Laravel 6.X

Laravel 7: Unable to prepare route [api/user] for serialization. Uses Closure. (LogicException) [duplicate]

This question already has answers here:
laravel Unable to prepare route ... for serialization. Uses Closure
(11 answers)
Closed 2 years ago.
I have installed laravel 7 in my local server. When I run php artisan route:cache command then laravel return error:
LogicException
Unable to prepare route [api/user] for serialization. Uses Closure.
How I can solve this problem?
I tried by running artisan commands:
php artisan config:cache
php artisan config:clear
php artisan cache:clear
composer dumpautoload
Here is content routes/api.php:
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
You can't cache your routes if they are using Closure.
// This is a Closure
// v
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Official docs (This is not new to Laravel 7) https://laravel.com/docs/5.8/deployment#optimization.
To make route:cache work, you may want to replace all requests using Closures to use a Controller method instead.
The route above, would then be like:
Route::middleware('auth:api')->get('/user', 'UserController#show');
And the controller method UserController#show would be like:
public function show(Request $request)
{
return $request->user();
}
Hope this helps! :)

Laravel: Route not found error

I have a newbie question in laravel. I'm trying to query a DB. I have already modified the config to include the necessary credentials for my DB. Now, when i try to query my DB like this:
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/', function()
{
$topPages = DB::table('webmasters') -> get();
return $topPages;
});
I get: Fatal error:
Class 'Route' not found in /.../.../.../dashboard/app/routes.php on
line 13.
I have followed laracast video for accessing a database to the letter, can someone pls tell me what i'm missing or doing wrong here?
Thanks in advance.
maybe the route cache issue run command
php artisan route:cache
Possible Solutions:
Update the app by composer (composer update)
Check for file permission

Categories