After I upgraded Laravel from 5.1 to 5.2
php artisan route:list
returns andempty list of routes. Also I got this error:
NotFoundHttpException
The file routes.php is in the app\Http folder. It seems that the file "routes.php" is not visible at all.
Are you using Route::controller? Laravel 5.2 deprecated that.
Implicit controller routes using Route::controller have been deprecated. Please use explicit route registration in your routes file. This will likely be extracted into a package.
Related
In the new Laravel 9 project, after installing the UI, I have a problem with the php artisan route:cache command. Message appears:
Unable to prepare route [password/reset] for serialization. Another
route has already been assigned name [password.request]. Checking
route:list, no duplicate route.
Everything is fine on the local server, but some routes are not working on the hosting.
Are the names of those route not the same?
By the name I mean the "name" method as follow bellow:
Route::get('/user', [UserController::class, 'index'])->name('thisMustBeAnUniqueName);
I am currently working on an API only laravel application. In the controllers folder, there is an API folder that holds all controllers. The ForgotPasswordController is in the API folder as well.
When I run the command php artisan route:list I get the error below
Illuminate\Contracts\Container\BindingResolutionException : Target class [App\Http\Controllers\Auth\ForgotPasswordController] does not exist.
There is actually no ForgotPasswordController in the Auth folder. How do I handle this issue?
You have to make sure you are doing php artisan route:cache priority.
If the problem still persists, can you disable the auth provider and try?
For the sake of time considering that the project is live and I need to churn out a couple of features, I have moved both ForgotPassword and ResetPassword controllers back into the Auth folder. Ran a test to make sure nothing has been broken (everything works fine) and now I am able to list out the routes.
If you have Auth::routes() or Route::auth() in your routes file that would be generating routes to the ForgotPasswordController.
You would need to not be calling that or you would need to pass the proper option to it to have it not register those routes:
Auth::routes(['reset' => false]);
Depending on the version you are using this may not work. If that is the case you will have to not use this method at all and register the routes you want/need yourself.
I am using Ubuntu 16.04 and installed Laravel 5.3 on desktop/Laravel/test directory. I have created a test.blade.php file in resources/view directory. I have also created routes.php in app/Http directory and added following code:
Route::get('/', function(){
return view('test');
});
When I enter command in terminal: php artisan serve and go to http://localhost:8000 url in browser, it shows default page of laravel after installation. Why it is not showing view I have created? I have also tried writing following code in routes.php:
Route::get('/', function(){
echo "Test";
})
But still it doesn't work. Is there anything I am missing?
Reference
By default, fresh Laravel 5.3 applications contain two HTTP route
files in a new top-level routes directory. The web and api route files
provide more explicit guidance in how to split the routes for your web
interface and your API.
The routes.php is moved to different folder in Laravel 5.3. Update routes/web.php file.
From the Laravel Documentation 5.3
The routes directory contains all of the route definitions for your application. By default, three route files are included with Laravel: web.php, api.php, and console.php.
The routes.php was there in previous version. But in laravel 5.3 the routes.php is moved to routes/web.php as Saumini Navaratnam said.
Just started out working with Laravel and Homestead.
I followed below guide for that :
https://www.youtube.com/watch?v=S3kaQDFJiis
and did everything exactly the same, but when I open my project Laravel/app/Http there's no routes.php file just kernel.php.
What could possibly cause this? How to fix this? Maybe I messed up something during installation? I did try to re-install everything, but I faced same problem.
If you're using the latest version of Laravel, the routes can now be found in
Laravel/routes/
This folder contains 3 different files each used for their respective consumption methods api web console
I think you are using laravel latest version which is "5.3.*".
From laravel 5.3 routes has found a new home which is under
projectname/routes/.
routes directory has 3 php file
api.php
console.php
web.php
You can check your Laravel version form projectname/composer.json under require as "laravel/framework": "5.3."*
Reference:
Laravel 5.3
Keep note that from Laravel 5.3 the routes.php file has been removed and moved to
laravel_project_folder/routes/web.php
laravel_project_folder/routes/api.php
See Laravel 5.3 Routing Docs & Laravel Upgrade Guide Section
Hope this helps!
You will find it in
1)routes/web.php
You can also read the use of api.php and console.php files as they are also used in routing
[BadMethodCallException]
Method controllers does not exist.
Route::controllers(['auth' => 'Auth\AuthController', 'password' => 'Auth\PasswordController',]);
How is in Laravel 5.3?
Thanks
The Route::controller() has been deprecated (notes can be seen in the upgrade from 5.2 -> 5.3 on the docs site)
Implicit controller routes using Route::controller have been deprecated. Please use explicit route registration in your routes file. This will likely be extracted into a package.
Instead you must explicitly list each route in not resourceful controllers like so:
Route::get('foo', 'FooController#foo');
If your question is aimed specifically at the auth routes only then as the comments on your question running php artisan make:auth or adding Auth::routes(); to your routes\web.php file should do the trick.
May few dependency cannot injected in your project when you install via composer. You can try again to install a new copy or write the following lines in your project directory using the terminal.
composer install
or you can write
composer dump-autoload
Hope you can fix the problem.