#!/usr/bin/env php command('install', function ($output) { should_be_sudo(); Valet\LaunchDaemon::install(); Valet\Configuration::install(); Valet\DnsMasq::install($output); Valet\LaunchDaemon::restart(); $output->writeln(PHP_EOL.'Valet installed successfully!'); }); /** * Add the current working directory to the paths configuration. */ $app->command('park', function ($output) { Valet\Configuration::addPath(getcwd()); $output->writeln("This directory has been added to Valet's paths."); }); /** * Remove the current working directory to the paths configuration. */ $app->command('forget', function ($output) { Valet\Configuration::removePath(getcwd()); $output->writeln("This directory has been removed from Valet's paths."); }); /** * Register a symbolic link with Valet. */ $app->command('link [name]', function ($name, $output) { $name = $name ?: basename(getcwd()); $linkPath = Valet\Site::link($name); $output->writeln('A ['.$name.'] symbolic link has been created in ['.$linkPath.'].'); }); /** * Display all of the registered symbolic links. */ $app->command('links', function () { passthru('ls -la '.VALET_HOME_PATH.'/Sites'); }); /** * Unlink a link from the Valet links directory. */ $app->command('unlink [name]', function ($name, $output) { $name = $name ?: basename(getcwd()); if (Valet\Site::unlink($name)) { $output->writeln('The ['.$name.'] symbolic link has been removed.'); } else { $output->writeln('A symbolic link with this name does not exist.'); } }); /** * Determine which Valet driver the current directory is using. */ $app->command('which', function ($output) { require __DIR__.'/drivers/require.php'; $driver = ValetDriver::assign(getcwd(), basename(getcwd()), '/'); if ($driver) { $output->writeln('This site is served by ['.get_class($driver).'].'); } else { $output->writeln('Valet could not determine which driver to use for this site.'); } }); /** * Stream all of the logs for all sites. */ $app->command('logs', function ($output) { $files = Valet\Site::logs(); if (count($files) > 0) { passthru('tail -f '.implode(' ', $files)); } else { $output->writeln('No log files were found.'); } }); /** * Display all of the registered paths. */ $app->command('paths', function ($output) { $paths = Valet\Configuration::read()['paths']; if (count($paths) > 0) { $output->writeln(json_encode($paths, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); } else { $output->writeln('No paths have been registered.'); } }); /** * Echo the currently tunneled URL. */ $app->command('fetch-share-url', function ($output) { retry(20, function () use ($output) { $response = Httpful\Request::get('http://127.0.0.1:4040/api/tunnels')->send(); $body = $response->body; if (isset($body->tunnels) && count($body->tunnels) > 0) { foreach ($body->tunnels as $tunnel) { if ($tunnel->proto == 'http') { return $output->write($tunnel->public_url); } } } throw new Exception("Tunnel not established."); }, 250); }); /** * Start the daemon services. */ $app->command('start', function ($output) { should_be_sudo(); Valet\LaunchDaemon::restart(); $output->writeln('Valet services have been started.'); }); /** * Restart the daemon services. */ $app->command('restart', function ($output) { should_be_sudo(); Valet\LaunchDaemon::restart(); $output->writeln('Valet services have been restarted.'); }); /** * Stop the daemon services. */ $app->command('stop', function ($output) { should_be_sudo(); Valet\LaunchDaemon::stop(); $output->writeln('Valet services have been stopped.'); }); /** * Uninstall Valet entirely. */ $app->command('uninstall', function ($output) { should_be_sudo(); Valet\LaunchDaemon::uninstall(); $output->writeln('Valet has been uninstalled.'); }); /** * Run the application. */ $app->run();