I'm experimenting with hyn/laravel-tenancy package. I am amazed how awesome it is, but I've run into issue.
$this->get('login', 'Auth\LoginController#showLoginForm')->name('login'); causes error Class Auth\LoginController does not exist. Same with Auth::routes().
But $this->get('login', 'App\Http\Controllers\Auth\LoginController#showLoginForm')->name('login'); works fine.
How do I fix this to use it as a web.php routing file?
Related
I have some issues with Laravel. I called php artisan route:cache and then the issues began. For example, the Auth routes (login etc.) can be called even if the User is logged in. Then the caching command seems to not clearing the routes. I noticed it because I put my Auth routes in the middleware guests because of the rendering of the Auth routes. After I ran route: clear it worked.
Also, the 404 routing doesn't work since that, because if I call a route that doesn't exist, then the Symfony Framework throws an error:
Symfony\Component\Routing\Exception\ResourceNotFoundException
That's my web.php:
Route::get("/installer","install\InstallController#index");
Route::group(["middleware"=>"guest"],function(){
Auth::routes();
Route::post("login","Auth\Logincontroller#authenticate");
});
Route::group(["middleware" => "auth"], function () {
Route::get("/logout","Auth\LoginController#logOut");
Route::get('/', "dashboard\DashboardController#index");
});
Also, the installer route doesn't work. I will always get redirected to localhost/dashboard (even if I change the route name). My domain for the Laravel is called raptor.debug, so I don't know why it's redirecting to localhost.
Can someone point out what I did wrong or is this a bug?
As Anas Bakro pointed out, the command php artisan route:cache will brick the app, when the folder of the controllers are lowercased.
I'm starting a new project with Laravel 5.7. I've made standard laravel Auth with artisan. It registered a new route in routes/web.php which is
Route::get('/home', 'HomeController#index')->name('home');
The problem is when i rename '/home' to '/admin' it doesn't work. It returns 'The requested resource /admin was not found on this server.' error.
I can replace '/home' with anything except '/admin'. Anything else works without a problem.
What is wrong with '/admin' and why can't i use '/admin' as a route?
You can't use this '/admin' route because your project may have 'admin' folder (but not listing file due server config).
Simply rename your admin folder or use '/admin/home' instead.
I'm working with the Laravel 5.6 framework and I want to move the routes file to another directory. I moved it to the ~/config/routes/web.php from the original ~/routes/web.php directory.
I then changed the mapWebRoutes method in my RouteServiceProvider to this:
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('config/routes/web.php'));
Now when I try to start up laravel I get the error:
In web.php line 14:
Class 'Route' not found
I already checked the aliases array in my app.php config file. There it's just the right class:
'Route' => Illuminate\Support\Facades\Route::class,
When I change my routes directory back to the original ~/routes/web.php directory, every works.
I also tried to import the class into the web.php routes file like this:
use Illuminate\Support\Facades\Route;
Then I received this error when trying to start up laravel.
In Facade.php line 218:
A facade root has not been set.
How can I make it so that I can move my routes file to another directory without getting this error?
Move them to a directory that isn't being scanned for a specific reason.
The config directory is specifically for config files and they get loaded very early in the process, before the providers ... that is how your application gets the list of providers to load, from the config file.
If you want to make a directory named random in the root of your project and put your routes there, just change the path appropriately in the RouteServiceProvider and you will be good.
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('path/routes/web.php'));
But path can not be config,
For example base_path('public/routes/web.php') but not base_path('config/routes/web.php')
i'm having an issue with laravel routing, i'm getting 404 HTTP errors when i try to access a specific route.
This is my routing config:
/** Api First Version Routes */
Route::prefix('v1')->group(function(){
// Auth Routes
Route::post('register', 'Api\AuthController#register')->name('register');
Route::post('login', 'Api\AuthController#login')->name('login');
});
My route seems to be accessible on artisan route list command output
but when i try to access through my SPA HTTP Client, it returns a not found http error, image below.
and this error just happens when i try to access the login route.
EDIT***
When i remove the route from the prefix group, it works fine, seems that the problem is just when i'm using routing prefix.
after many hours trying i have solved this problem, i tried to remember what modifications i did in my code before getting errors, so i remembered that i removed the code Passport::routes(); from my App\Providers\AuthServiceProvider.php file.
After adding it back to my AuthServiceProvider.php file all stuff worked again.
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.