Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPENEUROPA-375: add command to run PHP server on given site #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/commands/drupal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ command:
sites-subdir: ${drupal.site.sites_subdir}
drush-setup:
options:
config-dir: ${drupal.root}/drush
config-dir: ${drupal.root}/drush
35 changes: 35 additions & 0 deletions src/Commands/DrupalCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,39 @@ public function settingsSetup(array $options = [
$this->taskAppendConfiguration($options['root'].'/sites/default/default.settings.php', $this->getConfig())->setConfigKey('drupal.settings'),
]);
}

/**
* Run PHP server.
*
* Run a PHP server using default configuration values provided in local
* runner.yml.dist/runner.yml files.
*
* @command drupal:run-server
*
* @option root Drupal site root.
* @option base-url Drupal site base URL
* @option background Run in background.
*
* @aliases drupal:rs
*
* @param array $options
*
* @return \Robo\Contract\TaskInterface
*/
public function runServer(array $options = [
'root' => InputOption::VALUE_REQUIRED,
'base-url' => InputOption::VALUE_REQUIRED,
'background' => InputOption::VALUE_NONE,
])
{
$host = parse_url($options['base-url'], PHP_URL_HOST);
$port = parse_url($options['base-url'], PHP_URL_PORT);
$port = ($port === null) ? 80 : $port;

return $this->taskServer($port)
->rawArg('-dalways_populate_raw_post_data=-1')
->host($host)
->dir($options['root'])
->background($options['background']);
}
}
12 changes: 12 additions & 0 deletions tests/fixtures/simulation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@
contains:
- "AppendConfiguration('web/sites/default/default.settings.php'"

- command: 'drupal:run-server'
configuration: []
composer: ''
contains:
- "[Simulator] Running exec php -S 127.0.0.1:8888 -t build -dalways_populate_raw_post_data=-1"

- command: 'drupal:run-server --base-url=http://example.com'
configuration: []
composer: ''
contains:
- "[Simulator] Running exec php -S example.com:80 -t build -dalways_populate_raw_post_data=-1"

- command: 'drupal:site-setup'
configuration:
drupal:
Expand Down