Please share the route details.
route not found error
I get route note found error but when I write
PHP artisan route: list
it exists.
I try cache clear
PHP artisan optimize
and also i try all solutions on https://stackoverflow.com/questions/43715106/404-not-found-but-route-exist-in-laravel-5-4/52802757
still the error exist i am using ubuntu20.0 when i test it using my friend computer it is working
any solution ?
here is my route file
Route::prefix('promotions')->group(function () {
Route::get('/packages',[PackagesController::class,'getAvailablePackages']);
Route::get('/available_days',[PackagesController::class,'availableDays']);
Route::post('add_promotion',[CampainAddingController::class,'addPromotion']);
Route::get('/list_of_user_advert',[CampaignController::class,'listOfUserCampaign']);
Route::get('/list_of_advert_post/{advert_id}',[TelegramPostController::class,'advertsPost']);
});
If your routes are in api.php file then you need to prefix all your routes with /api
{{ url('api/promotions/packages') }}
Please check the network tab and add the 404 route to the question. @hasen39
why ? by default laravel prefix api route with /api
how you are accessing the route, what kind of error you are getting Share it in the thread
meanwhile you should create routes with name
Route::get('/packages',[PackagesController::class,'getAvailablePackages'])->name('promotions.packages');
route('promotions.packages');
for testing on feature test
You should use
php artisan optimize:clear
To clear all your caches.
As for your routes, you shouldn’t use a / prefix as laravel knows that routes will all begin with a slash. If you include it you can end up with weird caching issues which sometimes means caches don’t clear (and this is maybe why your route:list doesn’t play properly)
thank you for your help but i didnt understand what do you want to say
instead of
Route::get('/packages',[PackagesController::class,'getAvailablePackages']);
do
Route::get('packages',[PackagesController::class,'getAvailablePackages']);
no forward slash.
i chage it but still not working
Try this command
php artisan route:clear
if it willl work than you have problem with PHP versions.
PHP version on the web and in command-line interface have to be same version.
in terminal run php -v on the web run script with
<?php
phpinfo();
both are php 8.0
Show here the output of php artisan route:list since the order of your routes might be wrong.
+--------+----------+------------------------------------------------+------+---------------------------------------------------------------------------+------------------------------------------+
| | GET|HEAD | / | | Closure | web |
| | POST | api/auth/forgot_password | | App\Http\Controllers\Api\Auth\AuthController@forgotPassword | api |
| | | | | | App\Http\Middleware\SanctumGuest |
| | POST | api/auth/login | | App\Http\Controllers\Api\Auth\AuthController@login | api |
| | | | | | App\Http\Middleware\SanctumGuest |
| | POST | api/auth/register | | App\Http\Controllers\Api\Auth\AuthController@register | api |
| | | | | | App\Http\Middleware\SanctumGuest |
| | GET|HEAD | api/channel_catagory | | App\Http\Controllers\Catagory\CatagoryController@catagories | api |
| | | | | | App\Http\Middleware\Authenticate:sanctum |
| | POST | api/channels/register_channel | | App\Http\Controllers\Api\Channels\RegistrationController@register | api |
| | | | | | App\Http\Middleware\Authenticate:sanctum |
| | GET|HEAD | api/channels/users_channel/{user_id} | | App\Http\Controllers\Api\Channels\ChannelsController@listOfchannels | api |
| | | | | | App\Http\Middleware\Authenticate:sanctum |
| | GET|HEAD | api/csrf-cookie | | Laravel\Sanctum\Http\Controllers\CsrfCookieController@show | web |
| | POST | api/logout | | App\Http\Controllers\Api\Auth\AuthController@logOut | api |
| | | | | | App\Http\Middleware\Authenticate:sanctum |
| | POST | api/promotions/add_promotion | | App\Http\Controllers\Campaign\CampainAddingController@addPromotion | api |
| | | | | | App\Http\Middleware\Authenticate:sanctum |
| | GET|HEAD | api/promotions/available_days | | App\Http\Controllers\Api\Packages\PackagesController@availableDays | api |
| | | | | | App\Http\Middleware\Authenticate:sanctum |
| | GET|HEAD | api/promotions/edit_promotion/{advert_id} | | App\Http\Controllers\Campaign\CampainAddingController@editCampaign | api |
| | | | | | App\Http\Middleware\Authenticate:sanctum |
| | GET|HEAD | api/promotions/list_of_advert_post/{advert_id} | | App\Http\Controllers\Api\TelegramPost\TelegramPostController@advertsPost | api |
| | | | | | App\Http\Middleware\Authenticate:sanctum |
| | GET|HEAD | api/promotions/list_of_user_advert | | App\Http\Controllers\Campaign\CampaignController@listOfUserCampaign | api |
| | | | | | App\Http\Middleware\Authenticate:sanctum |
| | GET|HEAD | api/promotions/packages | | App\Http\Controllers\Api\Packages\PackagesController@getAvailablePackages | api |
| | | | | | App\Http\Middleware\Authenticate:sanctum |
+--------+----------+------------------------------------------------+------+---------------------------------------------------------------------------+------------------------------------------+
@hasen39 show the PackagesController@getAvailablePackages method here. Did you create custom request class and use it in PackagesController@getAvailablePackages method? If so then also show that request class. You might have false value returned for authorize method on the request class.
Clear Cache and clear route
not work
Please or to participate in this conversation.