Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master: (68 commits)
  Uses `actions/checkout@v4`
  Update CHANGELOG
  version
  Update CHANGELOG
  version
  Fix code styling
  Fix magento2 driver (laravel#1420)
  Update CHANGELOG
  version
  Fix code styling
  Fix code styling
  PHP 8.3 (laravel#1448)
  Update tests/CliTest.php
  Add conflict about mnapoli/silly 1.8.1–1.8.2
  Bump requirement for mnapoli/silly to 1.5+
  Add test of link command's isolate flag
  Ensure link command checks current directory for PHP version
  Improve link command's secure and isolate sub-commands
  Update CHANGELOG
  Fix code styling
  ...
  • Loading branch information
nickygerritsen committed Dec 14, 2023
2 parents 8ef5c1b + c4fb099 commit 8812c15
Show file tree
Hide file tree
Showing 47 changed files with 939 additions and 379 deletions.
23 changes: 0 additions & 23 deletions .github/ISSUE_TEMPLATE/1_Bug_report.md

This file was deleted.

37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/1_Bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Bug Report
description: "Report a general library issue."
body:
- type: markdown
attributes:
value: |
Before submitting your report, [please ensure your Laravel version is still supported](https://laravel.com/docs/releases#support-policy).
**Did you know? Most problems can be resolved by running 3 commands:**
- `composer self-update`
- `composer global update`
- `brew upgrade`
... in fact, it's good to run these commands at least once a month!
Alternatively, try to reboot your machine first to see if it solves your current issue.
- type: textarea
attributes:
label: Description
description: Provide a detailed description of the issue you are facing.
validations:
required: true
- type: textarea
attributes:
label: Steps To Reproduce
description: Provide detailed steps to reproduce your issue.
validations:
required: true
- type: textarea
attributes:
label: Diagnosis
description: Run `valet diagnose` and then paste the output here.
validations:
required: true


4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
strategy:
fail-fast: true
matrix:
php: ['8.0', 8.1, 8.2]
php: ['8.0', 8.1, 8.2, 8.3]

name: PHP ${{ matrix.php }}

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
51 changes: 50 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
# Release Notes

## [Unreleased](https://github.com/laravel/valet/compare/v4.0.1...master)
## [Unreleased](https://github.com/laravel/valet/compare/v4.5.0...master)

## [v4.5.0](https://github.com/laravel/valet/compare/v4.4.1...v4.5.0) - 2023-10-10

- Add support for proxying multiple domains at once by [@RobertBoes](https://github.com/RobertBoes) in https://github.com/laravel/valet/pull/1437

## [v4.4.1](https://github.com/laravel/valet/compare/v4.4.0...v4.4.1) - 2023-10-03

- Fix magento2 driver by [@mischabraam](https://github.com/mischabraam) in https://github.com/laravel/valet/pull/1420

## [v4.4.0](https://github.com/laravel/valet/compare/v4.3.0...v4.4.0) - 2023-09-26

- Allow LaravelValetDriver to serve other /public/*.php files by [@drbyte](https://github.com/drbyte) in https://github.com/laravel/valet/pull/1439
- Support static caching in Statamic by [@jasonvarga](https://github.com/jasonvarga) in https://github.com/laravel/valet/pull/1440
- Fix link command's `--isolate` argument with custom name by [@mcaskill](https://github.com/mcaskill) in https://github.com/laravel/valet/pull/1428

## [v4.3.0](https://github.com/laravel/valet/compare/v4.1.4...v4.3.0) - 2023-09-05

- Add "valet stop dnsmasq" option by [@drbyte](https://github.com/drbyte) in https://github.com/laravel/valet/pull/1422
- Drop Mailhog and Redis from default logs list, since Valet doesn't install them by [@mattstauffer](https://github.com/mattstauffer) in https://github.com/laravel/valet/pull/1438

## [v4.1.4](https://github.com/laravel/valet/compare/v4.1.3...v4.1.4) - 2023-08-14

### What's Changed

- Only delete DNSMasq resolver when Herd is not installed by [@mpociot](https://github.com/mpociot) in https://github.com/laravel/valet/pull/1434

**Full Changelog**: https://github.com/laravel/valet/compare/v4.1.3...v4.1.4

## [v4.1.3](https://github.com/laravel/valet/compare/v4.1.2...v4.1.3) - 2023-07-21

- Add quotes around $PHP by [@datashaman](https://github.com/datashaman) in https://github.com/laravel/valet/pull/1431

## [v4.1.2](https://github.com/laravel/valet/compare/v4.1.1...v4.1.2) - 2023-05-30

- Load specific drivers before custom drivers to allow for extension. by @mattstauffer in https://github.com/laravel/valet/pull/1414
- Ensure base configuration is correct even if file already exists by @mattstauffer in https://github.com/laravel/valet/pull/1415

## [v4.1.1](https://github.com/laravel/valet/compare/v4.1.0...v4.1.1) - 2023-05-16

- Install older PHP versions via alternate tap by @drbyte in https://github.com/laravel/valet/pull/1411

## [v4.1.0](https://github.com/laravel/valet/compare/v4.0.2...v4.1.0) - 2023-05-09

- Add driver for Radicle by @csorrentino in https://github.com/laravel/valet/pull/1413

## [v4.0.2](https://github.com/laravel/valet/compare/v4.0.1...v4.0.2) - 2023-04-26

- Fix ngrok.io proxy/forwarding detection by @drbyte in https://github.com/laravel/valet/pull/1404
- Fix read non existing config file by @mischabraam in https://github.com/laravel/valet/pull/1398

## [v4.0.1](https://github.com/laravel/valet/compare/v4.0.0...v4.0.1) - 2023-03-27

Expand Down
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Release Instructions

1. Update the `$version` variable in [`app.php`](./cli/app.php) and commit it
2. Create a new GitHub release for this version with the release notes
33 changes: 29 additions & 4 deletions cli/Valet/Brew.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

class Brew
{
// This is the array of PHP versions that Valet will attempt to install/configure when requested
const SUPPORTED_PHP_VERSIONS = [
'php',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
Expand All @@ -19,9 +21,22 @@ class Brew
'[email protected]',
];

const BREW_DISABLE_AUTO_CLEANUP = 'HOMEBREW_NO_INSTALL_CLEANUP=1';
// Update this LATEST and the following LIMITED array when PHP versions are released or retired
// We specify a numbered version here even though Homebrew links its generic 'php' alias to it
const LATEST_PHP_VERSION = '[email protected]';

const LATEST_PHP_VERSION = '[email protected]';
// These are the PHP versions that should be installed via the shivammathur/php tap because
// Homebrew officially no longer bottles them or they're marked disabled in their formula
// Cue: Homebrew reports "[email protected] has been disabled because it is a versioned formula"
const LIMITED_PHP_VERSIONS = [
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
];

const BREW_DISABLE_AUTO_CLEANUP = 'HOMEBREW_NO_INSTALL_CLEANUP=1';

public function __construct(public CommandLine $cli, public Filesystem $files)
{
Expand Down Expand Up @@ -72,6 +87,14 @@ public function supportedPhpVersions(): Collection
return collect(static::SUPPORTED_PHP_VERSIONS);
}

/**
* Get a list of disabled/limited PHP versions.
*/
public function limitedPhpVersions(): Collection
{
return collect(static::LIMITED_PHP_VERSIONS);
}

/**
* Get a list of installed PHP formulae.
*/
Expand Down Expand Up @@ -135,7 +158,9 @@ public function installOrFail(string $formula, array $options = [], array $taps
}

output('<info>['.$formula.'] is not installed, installing it now via Brew...</info> 🍻');
if ($formula !== 'php' && starts_with($formula, 'php') && preg_replace('/[^\d]/', '', $formula) < '73') {

if ($this->limitedPhpVersions()->contains($formula)) {
$formula = 'shivammathur/php/'.$formula;
warning('Note: older PHP versions may take 10+ minutes to compile from source. Please wait ...');
}

Expand Down Expand Up @@ -267,7 +292,7 @@ function ($version) use ($resolvedPhpVersion) {
*
* @param string|null $phpVersion For example, "[email protected]"
*/
public function getPhpExecutablePath(?string $phpVersion = null): string
public function getPhpExecutablePath(string $phpVersion = null): string
{
if (! $phpVersion) {
return BREW_PREFIX.'/bin/php';
Expand Down
24 changes: 22 additions & 2 deletions cli/Valet/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function install(): void
$this->createSitesDirectory();
$this->createLogDirectory();
$this->createCertificatesDirectory();
$this->writeBaseConfiguration();
$this->ensureBaseConfiguration();

$this->files->chown($this->path(), user());
}
Expand Down Expand Up @@ -84,7 +84,23 @@ public function createCertificatesDirectory(): void
}

/**
* Write the base, initial configuration for Valet.
* Ensure the base initial configuration has been installed.
*/
public function ensureBaseConfiguration(): void
{
$this->writeBaseConfiguration();

if (empty($this->read()['tld'])) {
$this->updateKey('tld', 'test');
}

if (empty($this->read()['loopback'])) {
$this->updateKey('loopback', '127.0.0.1');
}
}

/**
* Write the base initial configuration for Valet.
*/
public function writeBaseConfiguration(): void
{
Expand Down Expand Up @@ -152,6 +168,10 @@ public function prune(): void
*/
public function read(): array
{
if (! $this->files->exists($this->path())) {
return [];
}

return json_decode($this->files->get($this->path()), true, 512, JSON_THROW_ON_ERROR);
}

Expand Down
19 changes: 16 additions & 3 deletions cli/Valet/DnsMasq.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,21 @@ public function uninstall(): void
$this->brew->stopService('dnsmasq');
$this->brew->uninstallFormula('dnsmasq');
$this->cli->run('rm -rf '.BREW_PREFIX.'/etc/dnsmasq.d/dnsmasq-valet.conf');
$tld = $this->configuration->read()['tld'];
$this->files->unlink($this->resolverPath.'/'.$tld);

// As Laravel Herd uses the same DnsMasq resolver, we should only
// delete it if Herd is not installed.
if (! $this->files->exists('/Applications/Herd.app')) {
$tld = $this->configuration->read()['tld'];
$this->files->unlink($this->resolverPath.'/'.$tld);
}
}

/**
* Stop the dnsmasq service.
*/
public function stop(): void
{
$this->brew->stopService(['dnsmasq']);
}

/**
Expand All @@ -65,7 +78,7 @@ public function ensureUsingDnsmasqDForConfigs(): void
// set primary config to look for configs in /usr/local/etc/dnsmasq.d/*.conf
$contents = $this->files->get($this->dnsmasqMasterConfigFile);
// ensure the line we need to use is present, and uncomment it if needed
if (false === strpos($contents, 'conf-dir='.BREW_PREFIX.'/etc/dnsmasq.d/,*.conf')) {
if (strpos($contents, 'conf-dir='.BREW_PREFIX.'/etc/dnsmasq.d/,*.conf') === false) {
$contents .= PHP_EOL.'conf-dir='.BREW_PREFIX.'/etc/dnsmasq.d/,*.conf'.PHP_EOL;
}
$contents = str_replace('#conf-dir='.BREW_PREFIX.'/etc/dnsmasq.d/,*.conf', 'conf-dir='.BREW_PREFIX.'/etc/dnsmasq.d/,*.conf', $contents);
Expand Down
9 changes: 7 additions & 2 deletions cli/Valet/Drivers/LaravelValetDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public function serves(string $sitePath, string $siteName, string $uri): bool
*/
public function beforeLoading(string $sitePath, string $siteName, string $uri): void
{
// Shortcut for getting the "local" hostname as the HTTP_HOST
if (isset($_SERVER['HTTP_X_ORIGINAL_HOST'], $_SERVER['HTTP_X_FORWARDED_HOST'])) {
// Shortcut for getting the "local" hostname as the HTTP_HOST, especially when proxied or using 'share'
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}
}
Expand Down Expand Up @@ -52,6 +52,11 @@ public function isStaticFile(string $sitePath, string $siteName, string $uri)/*:
*/
public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string
{
if (file_exists($staticFilePath = $sitePath.'/public'.$uri)
&& $this->isActualFile($staticFilePath)) {
return $staticFilePath;
}

return $sitePath.'/public/index.php';
}
}
2 changes: 1 addition & 1 deletion cli/Valet/Drivers/Specific/ContaoValetDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function frontControllerPath(string $sitePath, string $siteName, string $
return $sitePath.'/web/install.php';
}

if (0 === strncmp($uri, '/app_dev.php', 12)) {
if (strncmp($uri, '/app_dev.php', 12) === 0) {
$_SERVER['SCRIPT_NAME'] = '/app_dev.php';
$_SERVER['SCRIPT_FILENAME'] = $sitePath.'/app_dev.php';

Expand Down
Loading

0 comments on commit 8812c15

Please sign in to comment.