mirror of
https://github.com/laravel/valet.git
synced 2026-02-06 00:40:06 +01:00
* Correct the return type annotation in a serves method * Type-hint the driver in the abstract ValetDriver * Correct the return type-hint in the sample ValetDriver * Remove the return afrom the restartLinkedPhp method * Remove the return annotation from the Caddy constructor * Remove the return annotation from the Valet configuration constructor * Removed the return from the prependPath method of the Configuration class * Removed the return from the appendAsUser method of the Filesystem class * Removed the return annotation from the Site constructor * Corrected the parameter annotation of the link method in the Site class * Order use statements by length in PhpFpm * Remove the return annotation from the Valet constructor
82 lines
2.0 KiB
PHP
82 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Valet;
|
|
|
|
class Valet
|
|
{
|
|
var $cli, $files;
|
|
|
|
var $valetBin = '/usr/local/bin/valet';
|
|
|
|
/**
|
|
* Create a new Valet instance.
|
|
*
|
|
* @param CommandLine $cli
|
|
* @param Filesystem $files
|
|
*/
|
|
function __construct(CommandLine $cli, Filesystem $files)
|
|
{
|
|
$this->cli = $cli;
|
|
$this->files = $files;
|
|
}
|
|
|
|
/**
|
|
* Symlink the Valet Bash script into the user's local bin.
|
|
*
|
|
* @return void
|
|
*/
|
|
function symlinkToUsersBin()
|
|
{
|
|
$this->cli->quietlyAsUser('rm '.$this->valetBin);
|
|
|
|
$this->cli->runAsUser('ln -s '.realpath(__DIR__.'/../../valet').' '.$this->valetBin);
|
|
}
|
|
|
|
/**
|
|
* Create the "sudoers.d" entry for running Valet.
|
|
*
|
|
* @return void
|
|
*/
|
|
function createSudoersEntry()
|
|
{
|
|
$this->files->ensureDirExists('/etc/sudoers.d');
|
|
|
|
$this->files->put('/etc/sudoers.d/valet', 'Cmnd_Alias VALET = /usr/local/bin/valet *
|
|
%admin ALL=(root) NOPASSWD: VALET'.PHP_EOL);
|
|
}
|
|
|
|
/**
|
|
* Get the paths to all of the Valet extensions.
|
|
*
|
|
* @return array
|
|
*/
|
|
function extensions()
|
|
{
|
|
if (! $this->files->isDir(VALET_HOME_PATH.'/Extensions')) {
|
|
return [];
|
|
}
|
|
|
|
return collect($this->files->scandir(VALET_HOME_PATH.'/Extensions'))
|
|
->reject(function ($file) {
|
|
return is_dir($file);
|
|
})
|
|
->map(function ($file) {
|
|
return VALET_HOME_PATH.'/Extensions/'.$file;
|
|
})
|
|
->values()->all();
|
|
}
|
|
|
|
/**
|
|
* Determine if this is the latest version of Valet.
|
|
*
|
|
* @param string $currentVersion
|
|
* @return bool
|
|
*/
|
|
function onLatestVersion($currentVersion)
|
|
{
|
|
$response = \Httpful\Request::get('https://api.github.com/repos/laravel/valet/releases/latest')->send();
|
|
|
|
return version_compare($currentVersion, trim($response->body->tag_name, 'v'), '>=');
|
|
}
|
|
}
|