diff --git a/.gitignore b/.gitignore
index d1502b0..ec60f71 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
vendor/
composer.lock
+error.log
diff --git a/Caddyfile b/Caddyfile
new file mode 100644
index 0000000..a8a7fb7
--- /dev/null
+++ b/Caddyfile
@@ -0,0 +1,12 @@
+:80
+
+fastcgi / 127.0.0.1:9000 php {
+ index server.php
+}
+
+rewrite {
+ r .*
+ to /server.php?{query}
+}
+
+errors ./error.log
diff --git a/caddy b/caddy
new file mode 100755
index 0000000..eb854ef
Binary files /dev/null and b/caddy differ
diff --git a/src/LaunchDaemon.php b/src/LaunchDaemon.php
index 62a18d9..99f9110 100644
--- a/src/LaunchDaemon.php
+++ b/src/LaunchDaemon.php
@@ -12,11 +12,9 @@ class LaunchDaemon
public static function install()
{
$contents = str_replace(
- 'SERVER_PATH', realpath(__DIR__.'/../server.php'), file_get_contents(__DIR__.'/../stubs/daemon.plist')
+ 'VALET_PATH', realpath(__DIR__.'/../'), file_get_contents(__DIR__.'/../stubs/caddyDaemon.plist')
);
- $contents = str_replace('PHP_PATH', exec('which php'), $contents);
-
file_put_contents('/Library/LaunchDaemons/com.laravel.valetServer.plist', $contents);
}
diff --git a/src/PhpFpm.php b/src/PhpFpm.php
new file mode 100644
index 0000000..16b3fcc
--- /dev/null
+++ b/src/PhpFpm.php
@@ -0,0 +1,92 @@
+run();
+
+ return in_array('php70', explode(PHP_EOL, $process->getOutput()));
+ }
+
+ /**
+ * Download a fresh copy of PHP 7.0 from Brew.
+ *
+ * @param OutputInterface $output
+ * @return void
+ */
+ public static function download($output)
+ {
+ $output->writeln('PHP 7.0 is not installed, installing it now via Brew... 🍻');
+
+ passthru('sudo -u '.$_SERVER['SUDO_USER'].' brew tap homebrew/dupes');
+ passthru('sudo -u '.$_SERVER['SUDO_USER'].' brew tap homebrew/versions');
+ passthru('sudo -u '.$_SERVER['SUDO_USER'].' brew tap homebrew/homebrew-php');
+
+ $process = new Process('sudo -u '.$_SERVER['SUDO_USER'].' brew install php70');
+
+ $processOutput = '';
+ $process->run(function ($type, $line) use (&$processOutput) {
+ $processOutput .= $line;
+ });
+
+ if ($process->getExitCode() > 0) {
+ $output->write($processOutput);
+
+ throw new Exception('We were unable to install PHP.');
+ }
+
+ $output->writeln('');
+ }
+
+ /**
+ * Update the PHP FPM configuration to use the current user.
+ *
+ * @return void
+ */
+ public static function updateConfiguration()
+ {
+ quietly('sed -i "" -e "s/^user = \_www/user = '.$_SERVER['SUDO_USER'].'/" /usr/local/etc/php/7.0/php-fpm.d/www.conf');
+
+ quietly('sed -i "" -e "s/^group = \_www/group = staff/" /usr/local/etc/php/7.0/php-fpm.d/www.conf');
+ }
+
+ /**
+ * Restart the PHP FPM process.
+ *
+ * @return void
+ */
+ public static function restart()
+ {
+ quietly('sudo brew services restart php70');
+ }
+}
diff --git a/stubs/caddyDaemon.plist b/stubs/caddyDaemon.plist
new file mode 100644
index 0000000..2e82077
--- /dev/null
+++ b/stubs/caddyDaemon.plist
@@ -0,0 +1,18 @@
+
+
+
+
+ Label
+ com.laravel.valetServer
+ WorkingDirectory
+ VALET_PATH
+ ProgramArguments
+
+ ./caddy
+
+ RunAtLoad
+
+ StandardErrorPath
+ /tmp/com.laravel.valetServer.err
+
+
diff --git a/valet.php b/valet.php
index f7c44cc..2324902 100755
--- a/valet.php
+++ b/valet.php
@@ -32,10 +32,14 @@
$app->command('install', function ($output) {
should_be_sudo();
+ Valet\LaunchDaemon::stop();
+
Valet\LaunchDaemon::install();
Valet\Configuration::install();
+ Valet\PhpFpm::install($output);
+
Valet\DnsMasq::install($output);
Valet\LaunchDaemon::restart();