Last active
April 2, 2020 21:50
-
-
Save dotnetCarpenter/b0801d4e5e5688de390ed4c1d7342450 to your computer and use it in GitHub Desktop.
`./artisan server` for Lumen 5.3. Kernel.php is in app/Console/ and ServeCommand should be created in app/Console/Commands/
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 characters
<?php | |
namespace App\Console; | |
use Illuminate\Console\Scheduling\Schedule; | |
use Laravel\Lumen\Console\Kernel as ConsoleKernel; | |
class Kernel extends ConsoleKernel | |
{ | |
/** | |
* The Artisan commands provided by your application. | |
* | |
* @var array | |
*/ | |
protected $commands = [ | |
// Our serve command | |
Commands\ServeCommand::class | |
]; | |
/** | |
* Define the application's command schedule. | |
* | |
* @param \Illuminate\Console\Scheduling\Schedule $schedule | |
* @return void | |
*/ | |
protected function schedule(Schedule $schedule) | |
{ | |
// | |
} | |
} |
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 characters
<?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 fire() | |
{ | |
chdir(base_path('public')); | |
$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} \"{$base}/public/index.php\""); | |
} | |
/** | |
* Get the console command options. | |
* | |
* @return array | |
*/ | |
protected function getOptions() | |
{ | |
return array( | |
array('host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', 'localhost'), | |
array('port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', 10420), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment