summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Pugh2017-12-01 15:35:45 -0500
committerJon Pugh2017-12-01 15:35:45 -0500
commit7918e2fb481ae9a9a0e146c51ce8d8275eafc8ee (patch)
tree0da572dd4c2f3433b093516cd3d876a722b50cf3
parent2caff8686973f1ee3264b8eef6243ebae85964bf (diff)
parent33cbdea7e6c540a719fe9d68f0e2c79e5279e897 (diff)
Merge branch 'php-server' of github.com:aegir-project/provision into php-serverphp-server
-rw-r--r--src/Common/ProcessAwareTrait.php68
-rw-r--r--src/Service/Http/Php/PhpServer.php79
-rw-r--r--src/ServiceInterface.php25
3 files changed, 172 insertions, 0 deletions
diff --git a/src/Common/ProcessAwareTrait.php b/src/Common/ProcessAwareTrait.php
new file mode 100644
index 0000000..6d15d0e
--- /dev/null
+++ b/src/Common/ProcessAwareTrait.php
@@ -0,0 +1,68 @@
+<?php
+
+namespace Aegir\Provision\Common;
+
+use Aegir\Provision\Context;
+use Symfony\Component\Process\Process;
+use Twig\Node\Expression\Unary\NegUnary;
+
+trait ProcessAwareTrait
+{
+ /**
+ * @var Process
+ */
+ protected $process = NULL;
+
+// /**
+// * @var string
+// */
+// protected $command;
+
+ /**
+ * @param Process $process
+ *
+ * @return $this
+ */
+ protected function setProcess(Process $process = NULL)
+ {
+ $this->process = $process;
+ return $this;
+ }
+
+ /**
+ * @return Process
+ */
+ public function getProcess()
+ {
+ if (is_null($this->process)) {
+ $this->process = new Process($this->command);
+ }
+ return $this->process;
+
+ }
+
+ /**
+ * @param $command
+ *
+ * @return $this
+ */
+ public function setCommand($command) {
+
+ $this->command = $command;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getCommand() {
+
+ return $this->command;
+ }
+
+ public function execute() {
+ $this->process->run();
+ }
+
+}
diff --git a/src/Service/Http/Php/PhpServer.php b/src/Service/Http/Php/PhpServer.php
new file mode 100644
index 0000000..8200d0d
--- /dev/null
+++ b/src/Service/Http/Php/PhpServer.php
@@ -0,0 +1,79 @@
+<?php
+
+namespace Aegir\Provision\Service\Http\Php;
+
+use Robo\Common\ExecCommand;
+use Robo\Common\ExecTrait;
+
+class PhpServer extends \Robo\Task\Development\PhpServer {
+
+
+ /**
+ * @var int
+ */
+ protected $port;
+
+ /**
+ * @var string
+ */
+ protected $host = '127.0.0.1';
+
+ /**
+ * @var string
+ */
+ protected $command = 'php -S %s:%d ';
+
+ /**
+ * @param int $port
+ */
+ public function __construct($port)
+ {
+ $this->port = $port;
+
+ if (strtolower(PHP_OS) === 'linux') {
+ $this->command = 'exec php -S %s:%d ';
+ }
+ }
+
+ /**
+ * @param string $host
+ *
+ * @return $this
+ */
+ public function host($host)
+ {
+ $this->host = $host;
+ return $this;
+ }
+
+ /**
+ * @param string $path
+ *
+ * @return $this
+ */
+ public function dir($path)
+ {
+ $this->command .= "-t $path";
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getCommand()
+ {
+ return sprintf($this->command, $this->host, $this->port);
+ }
+
+ public function run() {
+ $this->executeCommand($this->getCommand());
+ }
+
+ public function getProcess() {
+ return $this->process;
+ }
+
+ public function task() {
+
+ }
+} \ No newline at end of file
diff --git a/src/ServiceInterface.php b/src/ServiceInterface.php
new file mode 100644
index 0000000..eba930f
--- /dev/null
+++ b/src/ServiceInterface.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace Aegir\Provision;
+
+interface ServiceInterface
+{
+
+ /**
+ * Triggered on `provision verify` command on Site contexts.
+ */
+ public function verifySite();
+
+
+ /**
+ * Triggered on `provision verify` command on Platform contexts.
+ */
+ public function verifyPlatform();
+
+
+ /**
+ * Triggered on `provision verify` command on Site contexts.
+ */
+ public function verifyServer();
+
+} \ No newline at end of file