php - Laravel domain routing in production and dev

Solution:
The really easy solution would be to use a ternary operator to determine the TLD and use that in the group'sdomain
attribute:
Route::group(['domain' => 'admin.project.' . ((env('APP_ENV') == 'production') ? 'com' : 'app')], function()
{
Route::get('/', '[email protected]');
});
Avoiding duplication of code and adding additional environment variables.
Answer
Solution:
Does the same thing happen with a route param{}
instead of*
? I am not sure that laravel routing supports *:
Route::group(['domain' => 'admin.project.{tld}'], function()
{
Route::get('/', '[email protected]');
});
https://laravel.com/docs/5.2/routing#route-group-sub-domain-routing
Or what if you just used the domain as an ENV variable? In your env file locally, add:
APP_DOMAIN=admin.project.app
Then in the route file:
Route::group(['domain' => env("APP_DOMAIN","admin.project.com")],function(){
});
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: npm err! code 1
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.