#!/usr/bin/env php command('install', function () { Caddy::stop(); Configuration::install(); Caddy::install(); PhpFpm::install(); DnsMasq::install(); Caddy::restart(); output(PHP_EOL.'Valet installed successfully!'); }); /** * Change the domain currently being used by Valet. */ $app->command('domain domain', function ($domain) { DnsMasq::updateDomain( Configuration::read()['domain'], $domain = trim($domain, '.') ); Configuration::updateKey('domain', $domain); info('Your Valet domain has been updated to ['.$domain.'].'); }); /** * Get the domain currently being used by Valet. */ $app->command('current-domain', function () { info(Configuration::read()['domain']); }); /** * Add the current working directory to the paths configuration. */ $app->command('park', function () { Configuration::addPath(getcwd()); info("This directory has been added to Valet's paths."); }); /** * Remove the current working directory to the paths configuration. */ $app->command('forget', function () { Configuration::removePath(getcwd()); info("This directory has been removed from Valet's paths."); }); /** * Register a symbolic link with Valet. */ $app->command('link [name]', function ($name) { $linkPath = Site::link(getcwd(), $name = $name ?: basename(getcwd())); info('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) { Site::unlink($name ?: basename(getcwd())); info('The ['.$name.'] symbolic link has been removed.'); }); /** * Determine which Valet driver the current directory is using. */ $app->command('which', function () { require __DIR__.'/drivers/require.php'; $driver = ValetDriver::assign(getcwd(), basename(getcwd()), '/'); if ($driver) { info('This site is served by ['.get_class($driver).'].'); } else { output('Valet could not determine which driver to use for this site.'); } }); /** * Stream all of the logs for all sites. */ $app->command('logs', function () { $files = Site::logs(Configuration::read()['paths']); $files = collect($files)->transform(function ($file) { return escapeshellarg($file); })->all(); if (count($files) > 0) { passthru('tail -f '.implode(' ', $files)); } else { output('No log files were found.'); } }); /** * Display all of the registered paths. */ $app->command('paths', function () { $paths = Configuration::read()['paths']; if (count($paths) > 0) { output(json_encode($paths, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); } else { info('No paths have been registered.'); } }); /** * Echo the currently tunneled URL. */ $app->command('fetch-share-url', function () { output(Ngrok::currentTunnelUrl()); }); /** * Start the daemon services. */ $app->command('start', function () { PhpFpm::restart(); Caddy::restart(); info('Valet services have been started.'); }); /** * Restart the daemon services. */ $app->command('restart', function () { PhpFpm::restart(); Caddy::restart(); info('Valet services have been restarted.'); }); /** * Stop the daemon services. */ $app->command('stop', function () { PhpFpm::stop(); Caddy::stop(); info('Valet services have been stopped.'); }); /** * Uninstall Valet entirely. */ $app->command('uninstall', function () { Caddy::uninstall(); info('Valet has been uninstalled.'); }); /** * Run the application. */ $app->run();