PHP code example of lisandrop05 / laravel-multidomain

1. Go to this page and download the library: Download lisandrop05/laravel-multidomain library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lisandrop05 / laravel-multidomain example snippets


//$app = new Illuminate\Foundation\Application(
$app = new Lisandrop05\Multidomain\Foundation\Application(
    $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);

//use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Lisandrop05\Multidomain\Foundation\Http\Kernel as HttpKernel;

//use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Lisandrop05\Multidomain\Foundation\Console\Kernel as ConsoleKernel;

        //Illuminate\Queue\QueueServiceProvider::class,
        Lisandrop05\Multidomain\Queue\QueueServiceProvider::class,

$domainParams = [
    'domain_detection_function_web' => function() {
        return \Illuminate\Support\Arr::get($_SERVER,'HTTP_HOST');
    }
];

//$app = new Illuminate\Foundation\Application(
$app = new Lisandrop05\Multidomain\Foundation\Application(
    $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__), null, $domainParams
);

//$app = new Illuminate\Foundation\Application(
$app = new Lisandrop05\Multidomain\Foundation\Application(
    $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__),
    dirname(__DIR__) . DIRECTORY_SEPARATOR . 'envs'
);

php artisan vendor:publish 

php artisan domain:add site1.com 

php artisan domain:add site2.com 

php artisan domain:remove site2.com 

php artisan domain:update_env --domain_values='{"TOM_DRIVER":"TOMMY"}' 

 config-site2_com.php 
 

php artisan list --domain=site1.com 

 php artisan queue:work --domain=site1.com 
 

 php artisan queue:work --domain=site1.com --queue=default1
 

 php artisan queue:work --domain=site1.com --queue=default2