[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.
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.
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.
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
I am new on laravel, and I am making some test and following a tutorial. The matter is that I don´t know what I did two days ago that I got any defaults controllers (maybe only one... I don´t remember, for example: HomeController). I removed the project and create a new one... but now these defaults controllers don´t exit. And my routes.php on app/http folder is like this:
Route::get('/', function () {
return view('welcome');
});
ONLY THIS!!!
I remember that the routes.php file of the first laravel test project had something like: get("home")... or get("login"), etc...
Do I need to install them via artisan or something?
When installing Laravel, i. e. with this command composer create-project --prefer-dist laravel/laravel blog, there is no app/Http/Controller/HomeController.php generated.
You only get one route in your routes.php. That's it!
What you could do, of course, is:
Create a class HomeController.php in app/Htpp/Controllers - use php artisan make:controller HomeController
Change the route in your routes.php to utilize the new HomeController
Route::get('/', 'HomeController#index');
Another thing you may did in the past was running php artisan make:auth to initialize basic controller ands views to get a scaffold for logins/registers of users.
Maybe authentication? It will create some views and routes.
https://laravel.com/docs/5.2/authentication#authentication-quickstart
The command php artisan make:auth if you are using 5.2.*
no you don't if you want to create a controller just tphp artisan make:controller HomeController and a controller will be created for you :)