DEV Community

Roberto B.
Roberto B.

Posted on

Laravel Valet + PHP 7.4 + Homebrew

This is a temporary workouround that allows me to go on with the local development with Laravel + Valet + PHP7.4
Today I upgraded my PHP to 7.4.0 version.
I have a MacBook Pro and I use PHP installed via Homebrew.
The usual step are:

brew update
brew upgrade php
composer global update
valet install
Enter fullscreen mode Exit fullscreen mode

After "valet install" I had a problem: Unable to determine linked PHP when parsing '7.4'

Alt Text

This happens because the current version of Valet are not whistelisting PHP 7.4.
I jumped on

code ~/.composer/vendor/laravel/valet/cli/Valet/Brew.php
Enter fullscreen mode Exit fullscreen mode
class Brew
{
    const SUPPORTED_PHP_VERSIONS = [
        'php',
        'php@7.3',
        'php@7.2',
        'php@7.1',
        'php@7.0',
        'php@5.6',
        'php73',
        'php72',
        'php71',
        'php70',
        'php56'
    ];
Enter fullscreen mode Exit fullscreen mode

I added 'php@7.4', line:

class Brew
{
    const SUPPORTED_PHP_VERSIONS = [
        'php',
        'php@7.4',
        'php@7.3',
        'php@7.2',
        'php@7.1',
        'php@7.0',
        'php@5.6',
        'php73',
        'php72',
        'php71',
        'php70',
        'php56'
    ];
Enter fullscreen mode Exit fullscreen mode

I needed to do this workaround, until Valet will include php@7.4
Brew.php

Obviously this is not the official way to have php7.4 but, for me at the moment is working so it allows me to go on with Laravel development on php7.4 via Valet (at least for this weekend).

Top comments (3)

Collapse
 
regiszanandrea profile image
Regis Zanandrea • Edited

Laravel Valet added support to php 7.4 on version: v2.5.4: github.com/laravel/valet/releases/...

Collapse
 
altynbek07 profile image
Altynbek

I wrote instructions on how to switch between PHP versions in Laravel Valet: gist.github.com/bgarrant/b9a2f7fb8...

Collapse
 
nateritter profile image
Nate Ritter

Thank you. This was perfect.