0

I'm having some trouble accessing controllers from web.php and api.php in my Laravel 8 application. I've read this post and I've been through the docs, from which I uncommented $namespace in the RouteServiceProvider, but up to now I've had no luck.

This is my api.php file:

<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

use App\Http\Controllers;
use App\Http\Controllers\SoapController;


Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Route::get('currency', 'SoapController@show');

And below is the error that I get when I try and load the /api/currency route:

enter image description here

Does anyone know how to get this working if I've tried both explicit naming and uncommenting $namespace in ServiceRouteProvider? (also, I've run compoaser dump-autoload)

One consideration is that I've installed the notfalsedev / laravel-soap package to try and get SOAP support working, not sure if it is messing things up...

Cornel Verster
  • 1,664
  • 3
  • 27
  • 55
  • 1
    you are not referencing the class by its FQCN ... a `use` statement does not have any affect on a "string" – lagbox Sep 25 '20 at 12:06

1 Answers1

1

In Laravel 8 it's a bit different from old versions you have to do

Route::get('currency', [SoapController::class, 'show']);

Make sure you import SoapController

Refer to Laravel 8 Routing for more information

mmabdelgawad
  • 2,385
  • 2
  • 7
  • 15
  • Unfortunately even if I do this it still gives me the same error.. I have tried as both a string and fully qualified class name. – Cornel Verster Sep 25 '20 at 12:36