Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

pratikmore2796's avatar

Problem in routing | everytime creating new route shows route undefined?

I have created various routes in my laravel 9 application but whenever I am creating new route it takes some time to update and after few restarts and attempts it works fine. Do I need to clear view and cache every time? Example this is happening right now and I don't know where is the problem tried all possibilities such as route:list command. This is my web.php

Route::get('/', function () { return view('welcome'); });

Route::get('/dashboard', function () { return view('admin.index'); })->middleware(['auth','verified'])->name('dashboard');

Route::get('/clear-cache', function() { Artisan::call('view:clear'); return "view Cache is cleared"; });

// Admin all routes Route::controller(AdminController::class)->group(function() { Route::get('/admin/logout', 'logout')->name('admin.logout'); Route::get('/admin/profile', 'profile_page')->name('admin.profile'); Route::get('/edit/profile', 'profile_edit')->name('edit.profile'); });

require DIR.'/auth.php';

//code ends

Here I created edit.profile route I called the route in admin_profile_view.blade.php //Code

@extends('admin.admin_master') @section('admin')

Name : {{$adminData->name}}

User Email : {{$adminData->email}}

UserName : {{$adminData->username}}

Edit Profile @endsection //code ends Now in admin controller I created named AdminController.php //profile edit start public function profile_edit() { $id = Auth::user()->id; $editData = User::find($id); return view('admin.admin_profile_edit',compact('editData')); } //end profile edit I created this function Note: Other functions are working properly. Here is my admin_profile_edit.blade.php //code @extends('admin.admin_master') @section('admin')

Textual inputs

Here are examples of .form-control applied to each textual HTML5 <input> type.

Text Search Email URL Telephone Password Number Date and time Date Month Week Time Color Select Open this select menu One Two Three
</div>
@endsection //code-ends Now I am getting this error Symfony \ Component \ Routing \ Exception \ RouteNotFoundException PHP 8.1.2 9.24.0 Route [edit.profile] not defined.

Thank you in advanced, can anyone please tell me where I am doing this mistake? This error occurs every-time when I am creating new route

0 likes
6 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Do you ever run any of the caching commands while developing? You should not. Try php artisan optimize:clear and be sure that you never run php artisan optimize in dev again :)

pratikmore2796's avatar

@Sinnbeck Thank You it worked!

I want to know why this things happens because it is same with css so everything works fine but every-time when I create new page, the css of it is not working then again I need to clear everything the views and cache is there any specific solution for this?

Sinnbeck's avatar

@pratikmore2796 might be the same. The optimize command caches everything, so it won't pick up any changes. If it happens again, make a fresh post and we will help you out :)

Please or to participate in this conversation.