Last active
March 17, 2024 11:18
-
-
Save brcontainer/44f47d35f47cd4e33f14023f8521bea1 to your computer and use it in GitHub Desktop.
Revisions
-
brcontainer revised this gist
Feb 22, 2021 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -48,11 +48,13 @@ protected function getOptions() { $url = env('APP_URL'); return [ [ 'host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', parse_url($url, PHP_URL_HOST) ], [ 'port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', parse_url($url, PHP_URL_PORT) ], ]; } } -
brcontainer created this gist
Feb 15, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ Copy `ServeCommand.php` to `app/Console/Commands/` folder and edit `app/Console/Kernel.php` and put `ServerCommand`, like this: ```php <?php namespace App\Console; use Illuminate\Console\Scheduling\Schedule; use Laravel\Lumen\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel { protected $commands = [ Commands\ServeCommand::class, ]; ``` If you run the command: ``` php artisan serve ``` will start the local server based on `APP_HOST` (from your `.env`) You can change the host or port: ``` php artisan serve --host 0.0.0.0 --port 8000 ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ <?php namespace App\Console\Commands; use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; class ServeCommand extends Command { /** * The console command name. * * @var string */ protected $name = 'serve'; /** * The console command description. * * @var string */ protected $description = "Serve the application on the PHP development server"; /** * Execute the console command. * * @return void */ public function handle() { $host = $this->input->getOption('host'); $port = $this->input->getOption('port'); $base = $this->laravel->basePath(); $this->info("Lumen development server started on http://{$host}:{$port}/"); passthru('"' . PHP_BINARY . '"' . " -S {$host}:{$port} -t \"{$base}/public\""); } /** * Get the console command options. * * @return array */ protected function getOptions() { $url = env('APP_URL'); return array( array('host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', parse_url($url, PHP_URL_HOST)), array('port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', parse_url($url, PHP_URL_PORT)), ); } }