I have a new Laravel project running Valet + (laravel 8.12).
Controller:
app->Http->Controllers->PageController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PageController extends Controller
{
public function dashboard()
{
return view('show');
}
}
Web.php
Route::get('/', function () {
return view('home');
});
Route::get(
'/dashboard',
[PageController::class, 'show']
)->name('dashboard');
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
I have a link on my homepage href="dashboard" however when this link is clicked I get an error:
lluminate\Contracts\Container\BindingResolutionException
Target class [PageController] does not exist.
http://myportal.test/dashboard
I have tried running: composer dump-autoload php artisan route:cache php artisan optimize php artisan clear-compiled
I dont fully understand why when I added php artisan ui vue --auth why the routing had [App\Http\Controllers\HomeController::class added for the route?
I have usually used: route::get('/dashboard', 'PageController@show'); which usually works.
None of these have worked to solve the issue. I have another Laravel project running in the same Valet+ environment that is working fine (although using a different version of Laravel).
I haven't been able to find a solution to my problem online that has helped me solve this problem. Can anyone point me in the right direction please?
Change
to