This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/app/Console/Command/ServeCommand.php

42 lines
933 B
PHP
Raw Permalink Normal View History

2016-02-19 22:49:00 +01:00
<?php
/**
* Holds the serve command controller.
* @package Sakura
*/
namespace Sakura\Console\Command;
use CLIFramework\Command;
2016-08-05 04:35:37 +02:00
/**
* Starts up a development server.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
2016-02-19 22:49:00 +01:00
class ServeCommand extends Command
{
2016-08-05 04:35:37 +02:00
/**
* A quick description of this command.
* @return string.
*/
2016-12-04 17:33:52 +01:00
public function brief(): string
2016-02-19 22:49:00 +01:00
{
return 'Sets up a local development server.';
}
2016-08-05 04:35:37 +02:00
/**
* Sends the php serve command via the exec command.
*/
2016-12-04 17:33:52 +01:00
public function execute(): void
2016-02-19 22:49:00 +01:00
{
$document_root = addslashes(path('public'));
$router_proxy = addslashes(path('server.php'));
2016-03-25 02:31:57 +01:00
$php_dir = PHP_BINDIR;
2016-07-26 19:29:53 +02:00
$host = config('dev.host');
2016-03-25 02:31:57 +01:00
2016-07-30 15:48:09 +02:00
$this->getLogger()->writeln("Starting Sakura development server on {$host}.");
2016-03-25 02:31:57 +01:00
exec("{$php_dir}/php -S {$host} -t {$document_root} {$router_proxy}");
2016-02-19 22:49:00 +01:00
}
}