Today, We want to share with you PHP Laravel 6 Sub-domain routing file Example.In this post we will show you wordpress plugin require another plugin, hear for Create and Use Dynamic Laravel Subdomain Routing we will give you demo and example for implement.In this post, we will learn about Subdomain routing and parameters in laravel 6 with an example.
PHP Laravel 6 Sub-domain routing file Example
There are the Following The simple About Sub-domain and main domain using same laravel application, Full Information With Example and source code.
As I will cover this Post with live Working example to develop laravel subdomain routing localhost, so the laravel dynamic domain is used for this example is following below.
Phase 1 : Install Laravel 6 New Web Application
Laravel Sub-domain routing & resource controllers
composer create-project --prefer-dist laravel/laravel angular_king
Phase 2 : Add Sub-Domain in ServiceProvider
app/Providers/RouteServiceProvider.php
<?php namespace App\Providers; use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; class RouteServiceProvider extends ServiceProvider { protected $namespace = 'App\Http\Controllers'; public function boot() { parent::boot(); } public function map() { $this->mapApiRoutes(); $this->mapWebRoutes(); $this->mapAdminRoutes(); $this->mapUserRoutes(); } protected function mapWebRoutes() { Route::middleware('web') ->namespace($this->namespace) ->group(base_path('routes/web.php')); } protected function mapApiRoutes() { Route::prefix('api') ->middleware('api') ->namespace($this->namespace) ->group(base_path('routes/api.php')); } protected function mapAdminRoutes() { Route::namespace($this->namespace) ->group(base_path('routes/admin.php')); } protected function mapUserRoutes() { Route::namespace($this->namespace) ->group(base_path('routes/user.php')); } }
Phase 3 : Add a simple Sub-Domain Routes
create a simple three domain using virtualhost
1) tamilrokers.dsp 2) admin.tamilrokers.dsp 3) user.tamilrokers.dsp
Define a Laravel 6 routes
routes/web.php : Web Routes
Route::get('/', function () { dd('Greeting to main domain.'); });
routes/admin.php
<?php Route::get('/', function () { dd('Greeting to admin subdomain.'); });
routes/user.php :User Routes
<?php Route::get('/', function () { dd('Greeting to user subdomain.'); });
Web Programming Tutorials Example with Demo
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about laravel 6 route controller.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donโt forget to share.