dingo / api

A RESTful API package for the Laravel and Lumen frameworks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Target class does not exist (Controller not found)

jamols09 opened this issue · comments

Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 7.x
Package version 3.x.y
PHP version 7.3.18

Actual Behaviour

Whenever I try to load a class it will always display an error that Target Class is not found even I have specified the exact location of the file.

$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function ($api) {

    // This Will Work
    // $api->get('hello', function() {
    //     return "hi";
    // });
    
    //Will not work
    $api->get('hello', 'app\Http\Controllers\TestController@index');
    // $api->get('hi','app\Api\Controllers\TestController@index');
});

Error Message:
message: "Target class [app\Http\Controllers\TestController] does not exist.", status_code: 500,

Screenshot of the File location
image

Expected Behaviour

In the TestController it should only display a "hi" text. However I can only display the "hi" text if I write in on the route api.php

Steps to Reproduce

Possible Solutions

Not sure

Found the Issue

On my route 'hello' the name of path Should have a capitalized first letter. App\Http\Controller\.. instead of app\Http\Controller\..

commented

Glad you solved it!