#about routes/api.php

27 messages · Page 1 of 1 (latest)

rigid nova
#

why my routes/api.php not working and when i do php artisan route:list cant see the api/

ps. sorry about the 1st post hope you understand

candid rock
#

Did you register your api routes file?

#

Also, just to make sure it's not a cache issue, run php artisan optimize:clear

rigid nova
#

hello sir

#

but when i go php artisan route:list

#

i got this but i have propertycontroller in app/http/controllers

#

is my laravel not working properly?

candid rock
#

is the namespace declaration in your controller correct?

rigid nova
#

yes like this sir namespace App\Http\Controllers;

candid rock
#

Where are you using it?

rigid nova
#

in propertycontroll and in my api.php use App\Http\Controllers\PropertyController;

candid rock
#

Show us the code where you're using it

#

The snippets you showed so far weren't actually using that class

gritty estuary
candid rock
rigid nova
#

wait sir ill recreate it so it looks like neet sorry

rigid nova
#

still not popping up the api/ when i called it

gritty estuary
#

Looks like you've changed quite some things, as a default Laravel 11 app wouldn't contain a RouteServiceProvider. So you're probably overwriting things, or at least something that would cause things to not work

rigid nova
#

i see sir ill delete RouteServiceProvider the AI ask me to create it because the api dont work on me only web.php

#

Route::get('/test', function () {
return response()->json([
'message' => 'API is working!',
'status' => 'success'
]);
});

#

i wondering sir why when i put php artisan route:list i cant see api/ there

gritty estuary
#

Honestly, ditch AI.

#

For one, it's confidently incorrect. If you're learning that can really bite you in the ass. It can be helpful if you understand what it's telling, if you know the underlying concepts etc. If you don't, you're just blindly copying things. When it's incorrect, you copy that too.

#

So likely you made other changes that just cause things to not work. And it's rather impossible to help without knowing what's changed, and since you don't know either, there might be lots of issues/changes..

rigid nova
#

i learn somethings here sir and yep some of it is blindly copy codes to ensure if its work or not thats why i dont still know why my api.php is not working properly i try to create and create new laravel folder to see if others will work but not all working they all working in web.php not in my api.php 😭

gritty estuary
rigid nova
#

wow i didnt modify it sir wait lemme check the docs again thankyou for the time