mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 00:20:08 +01:00
107 lines
2.3 KiB
PHP
Executable File
107 lines
2.3 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
|
|
if (file_exists(__DIR__.'/vendor/autoload.php')) {
|
|
require __DIR__.'/vendor/autoload.php';
|
|
} else {
|
|
require __DIR__.'/../../autoload.php';
|
|
}
|
|
|
|
should_be_compatible();
|
|
|
|
use Silly\Application;
|
|
|
|
/**
|
|
* Create the application.
|
|
*/
|
|
$app = new Application('Laravel Malt', 'v0.1.2');
|
|
|
|
/**
|
|
* Allow Malt to be run more conveniently by allowing the Node proxy to run password-less sudo.
|
|
*/
|
|
$app->command('install', function ($output) {
|
|
should_be_sudo();
|
|
|
|
Malt\LaunchDaemon::install();
|
|
|
|
Malt\Configuration::install();
|
|
|
|
Malt\DnsMasq::install($output);
|
|
|
|
$output->writeln(PHP_EOL.'<info>Malt installed successfully!</info>');
|
|
});
|
|
|
|
/**
|
|
* Add the current working directory to the paths configuration.
|
|
*/
|
|
$app->command('serve', function ($output) {
|
|
should_be_sudo();
|
|
|
|
Malt\Configuration::addPath(getcwd());
|
|
|
|
Malt\LaunchDaemon::restart();
|
|
|
|
$output->writeln('<info>This directory has been added to your serve paths!</info>');
|
|
});
|
|
|
|
/**
|
|
* Add the current working directory to the paths configuration.
|
|
*/
|
|
$app->command('logs', function ($output) {
|
|
$paths = Malt\Configuration::read()['paths'];
|
|
|
|
$files = [];
|
|
|
|
foreach ($paths as $path) {
|
|
foreach (scandir($path) as $directory) {
|
|
if (! in_array($directory, ['.', '..']) && file_exists($logPath = $path.'/'.$directory.'/storage/logs/laravel.log')) {
|
|
$files[] = $logPath;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (count($files) > 0) {
|
|
passthru('tail -f '.implode(' ', $files));
|
|
} else {
|
|
$output->writeln('No log files were found.');
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Add the current working directory to the paths configuration.
|
|
*/
|
|
$app->command('restart', function ($output) {
|
|
should_be_sudo();
|
|
|
|
Malt\LaunchDaemon::restart();
|
|
|
|
$output->writeln('<info>Malt services have been restarted.</info>');
|
|
});
|
|
|
|
/**
|
|
* Add the current working directory to the paths configuration.
|
|
*/
|
|
$app->command('stop', function ($output) {
|
|
should_be_sudo();
|
|
|
|
Malt\LaunchDaemon::stop();
|
|
|
|
$output->writeln('<info>Malt services have been stopped.</info>');
|
|
});
|
|
|
|
/**
|
|
* Add the current working directory to the paths configuration.
|
|
*/
|
|
$app->command('uninstall', function ($output) {
|
|
should_be_sudo();
|
|
|
|
Malt\LaunchDaemon::uninstall();
|
|
|
|
$output->writeln('<info>Malt has been uninstalled.</info>');
|
|
});
|
|
|
|
/**
|
|
* Run the application.
|
|
*/
|
|
$app->run();
|