#about routes/api.php
27 messages · Page 1 of 1 (latest)
Did you register your api routes file?
Also, just to make sure it's not a cache issue, run php artisan optimize:clear
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?
is the namespace declaration in your controller correct?
yes like this sir namespace App\Http\Controllers;
Where are you using it?
in propertycontroll and in my api.php use App\Http\Controllers\PropertyController;
Show us the code where you're using it
The snippets you showed so far weren't actually using that class
Think that error would show up if you'd do something like Route::get('/', 'PropertyController@index'), and that syntax you shouldn't use anymore
Literally looking over my shoulder and beating me to it wtf bobert
wait sir ill recreate it so it looks like neet sorry
still not popping up the api/ when i called it
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
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
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..
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 😭
But like, did you run this command as explained in the docs? https://laravel.com/docs/11.x/routing#api-routes or at least modify your bootstrap/app.php?
wow i didnt modify it sir wait lemme check the docs again thankyou for the time