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.
Related
I'm using bitfumes/laravel-multiauth Admin, I added my routes to the routes/admin.php but it shows me this error that it can't find my contoller.
Target class
[Bitfumes\Multiauth\Http\Controllers\admin\DashboardController] does
not exist.
route/admin.php
Route::get('/dashboard', 'DashboardController#index');
should I move my controllers to path specified in the vendor ?
Btw, this my first time for using this package, so I don't know how to deal with it.
I followed all the instructions in github.But now I'm trying to modify it in order to make it work for my project.
My controllers only work only if add them to the vendor directroy :
vendor/bitfumes/laravel-multiauth/src/http/controllers
But this is not practical if I published the project or pushed the project to github that folder will be ignored with the vendor folder.
I found the solution for this Problem
In routes/admin.php
Add path to your controller :\App\Http\Controllers\Admin\PlaceController
Route::resource('/places','\App\Http\Controllers\Admin\PlaceController')->middleware('role:super');
I tried to make an authentication page with Laravel and I simply made it with php artisan make:auth
The code was generated into Controllers and as view, in /resources/views/auth. I moved the folder into another folder: /resources/views/admin/auth and now I get this error:
View [auth.login] not found.
For routes I used: Auth::routes(['register' => false]);
What can I do now?
It looks for a view under /views/auth/login, however you moved the files to /views/admin/auth - everything is under admin.
You have to move the views back up one directory, or customise the routes in the AuthController.
I'm running a laravel project behind a reversed proxy which is why I need to force the root url and scheme:
URL::forceRootUrl($proxy_url);
URL::forceScheme($proxy_schema);
I've added this to the top of my /routes/web.php and it's working fine until I run:
php artisan optimize
It caches the routes in /bootstrap/cache without the forced url and scheme, so now all my urls are pointing to the wrong root url.
I've tried to move the code to /Providers/AppServiceProvider.php (both register and boot) in order to make it take effect when caching the routes but no luck.
I have to manually delete the routes cache file in /bootstrap/cache to make my routes work again.
Have do I make it take effect when caching the routes?
Edit:
I have also tried to create a global middleware where I do the force url and schema. Again it works fine before caching the routes, but when running php artisan optimize the routes are once again incorrect.
php artisan optimize removed since laravel 5.6 (source, source2)
Using URL::forceRootUrl and URL::forceScheme seems like a work-around for working with reverse proxies. The clean solution for it would be to add a trusted proxies in your configuration. This post explains the feature in full. But it comes down to:
Use the App\Http\Middleware\TrustProxies middleware
Edit the middleware $proxies property with the IP(s) of your load balancer
protected $proxies = [
'192.168.1.1',
'192.168.1.2',
];
Remove the following code from /routes/web.php
URL::forceRootUrl($proxy_url);
URL::forceScheme($proxy_schema);
I have to download some files from my webapp with laravel 5.6 and I am using the local storage.
I have my routes like downloads/{file} with the auth middleware and it's working properly.
The storage url is the default from laravel www.myweb.com/storage/files/ ...
the thing is if I use the route www.myweb.com/downloads/foo.pdf the controller is working properly and i must be logged in to download the file
but if I access from www.myweb.com/storage/files/foo.pdf I can see the file without being logged in
How can i solve this? should i create another controller or route to handle this?
should i create a route like
Route::get('/storage/files/{file}', 'FilesController#download')->middleware('auth');
/storage/files is already actual path of the storage. to avoid conflict change your route to other path
Route::get('/storage/files/{file}', 'FilesController#download')->middleware('auth');
change to (sample)
Route::get('/files/{file}/download', 'FilesController#download')->middleware('auth');
then do your logic in FilesController
I have been working with laravel 4 for some time now and i needed to create an admin area so i decided to use a package to keep things all organized and separated from the rest of the application.
So i created a package with composer as 'vendor/admin'.
then i added those lines as documemented on laravel site
AdminServiceProvider.php
public function boot()
{
$this->package('vendor/admin', 'admin');
include __DIR__.'/../../routes.php';
}
public function register()
{
//
$this->package('vendor/admin');
}
I also created a routes.php file in vedor/admin/ directory to route all admin area in this file.
following i run the 'php artisan dump-autoload' and i finalized with this commend on artisan 'php artisan config:publish vendor/admin'
now i wanna be able use this package for mysite.com/admin route and i want the routes.php file in the package to render the routing for that URI, to do that:
Do i need to modify my app/routes.php?
How can i make vendor/admin/src/routes.php file to do the routing for all mysite.com/admin routes?
Thanks.
No you don't need to edit app/routes.php. As long as it doesn't contain any admin routes that could collide with the ones in your package you can leave it that way.
The routes file in a package can be used like the "normal" app/routes.php. An easy way to deal with admin routes is to have a prefix group:
Route::group(array('prefix' => 'admin'), function(){
// all your admin routes. for example:
Route::get('dashboard', '...');
// will match GET /admin/dashboard
});
Besides that, make sure you're package gets loaded correctly! One part being registering the service provider. Assuming the namespace of your package is Admin you need to add Admin\AdminServiceProvider to the providers array in app/config/app.php. More information