Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: find-usable-php.php does not get automatically updated after installing php 8.3 #290

Closed
ghost opened this issue Jan 3, 2024 · 11 comments

Comments

@ghost
Copy link

ghost commented Jan 3, 2024

Operating system version

macOS Sonoma 14.2.1

System architecture

ARM64 (M1, M2, etc)

Herd Version

1.3.1 (Build: 18)

PHP Version

PHP 8.3.0

Bug description

After installing PHP8.3 find-usable-php.php does not get updated. Ergo it can not find the right version of PHP.

I don't know if it is a bug or by design since the problem only arose after I removed PHP 8.2

After finding this I think the desired behavior would be that Herd automatically updates find-usable-php.php so it can find 8.3 even if the user removes any other version of PHP.

As follows: (which I added manually to get it back to work)

<?php

$minimumPhpVersion = '8.0';

// First, check if the system's linked "php" is 8+; if so, return that. This
// is the most likely, most ideal, and fastest possible case
$linkedPhpVersion = shell_exec('php -r "echo phpversion();"');

if (version_compare($linkedPhpVersion, $minimumPhpVersion) >= 0) {
    if (file_exists($_SERVER['HOME'].'/Library/Application Support/Herd/bin/php83')) {
        echo $_SERVER['HOME'].'/Library/Application Support/Herd/bin/php83';
    } elseif (file_exists($_SERVER['HOME'].'/Library/Application Support/Herd/bin/php82')) {
        echo $_SERVER['HOME'].'/Library/Application Support/Herd/bin/php82';
    } elseif (file_exists($_SERVER['HOME'].'/Library/Application Support/Herd/bin/php81')) {
        echo $_SERVER['HOME'].'/Library/Application Support/Herd/bin/php81';
    } elseif (file_exists($_SERVER['HOME'].'/Library/Application Support/Herd/bin/php80')) {
        echo $_SERVER['HOME'].'/Library/Application Support/Herd/bin/php80';
    }

    return;
}

echo $_SERVER['HOME'].'/Library/Application Support/Herd/bin/php83';

Kind regards,
RL

Steps to reproduce

  1. Install PHP 8.3 using the herd interface
  2. Update all your sites to use 8.3 instead 8.2
  3. Remove PHP 8.2 by manually removing the executables from ~/Library/Application Support/Herd/bin
    and also The config files for 8.2 from ~/Library/Application Support/Herd/config/fmp and ~/Library/Application Support/Herd/config/php
  4. Restart Herd so now it only uses 8.3 and fpm 8.3
  5. Open your terminal and try to run herd.

Relevant log output

❯ herd
Error finding executable PHP. Quitting for safety.
Provided output from find-usable-php.php:
@kurucu
Copy link

kurucu commented Jan 28, 2024

And there's me thinking this is just me. Any risks with editing find-usable-php.php, or will it be overwritten on the next update?

@mpociot
Copy link
Member

mpociot commented Jan 28, 2024

You can manually fix it by now. The new version with the fix will be available in one week 🙂

@kurucu
Copy link

kurucu commented Jan 28, 2024

The manual fix works wonders. Thanks guys.

@williamtcastro
Copy link

For me the file rewrites back to 8.2 after restarting herd.

@sschlein
Copy link
Member

sschlein commented Feb 6, 2024

1.4. with a fix was released yesterday :)

@sschlein sschlein closed this as completed Feb 6, 2024
@MouhamedMokkhtar
Copy link

1.4. with a fix was released yesterday :)

now it doesn't support 7.4 !!

@mpociot
Copy link
Member

mpociot commented Feb 6, 2024

It didn't support PHP 7.4 before. This file gets used to find a usable PHP version for the Herd CLI, which requires 8.0 at least.

@nathandaly
Copy link

nathandaly commented Feb 6, 2024

1.4. with a fix was released yesterday :)

@sschlein Not so sure about that 😛

Currently at LaraconEU trying it out.

I'm also on Sonoma 14.2.1 (23C71).

Screenshot 2024-02-06 at 14 39 23

Noticed I don't have a php{version} folder in the specified bin path.

Screenshot 2024-02-06 at 14 48 12

The Herd process is running but no UI.

@otherperspectives
Copy link

otherperspectives commented Mar 20, 2024

I am also having this issue with Herd 1.5 for 8.3 PHP when I use "herd restart"

@amiralidev
Copy link

Navigate to the bin path of the "herd" folder within Application Support. Then, use the ls -la command to identify which version of PHP is linked to the "php" file.

If that version of PHP is missing, install it. This should resolve the issue I encountered where PHP was missing after installation.

@legecha
Copy link

legecha commented Dec 19, 2024

Sorry for commenting on an old issue, however I came here directly from Google and I thought it might be worth putting it here for anyone else coming, as well as you guys in case you want to add a safeguard.

Installed fresh just now (M4 MacBook) and I installed 8.4, and got rid of 8.3 as I thought I might as well just have the version I'm using.

However, none of the command line stuff worked. I checked find-usuable-php.php and it appears it only looks for 83, 82, 81 and 80 - so at least one of these is required for everything to work.

The herd command then uses 8.3, however composer, php, etc will use 8.4. I presume that's not going to cause any issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants