...

Set PHP Version Parity

As much as I enjoy working with Laravel Valet and using Homebrew to manage different versions of PHP, there are still times in which my system has been set up in such a way that my shell is using one version of PHP and Laravel is using a different version.

At the time of this post, I see the following whenever which I run $ which php:

/opt/homebrew/opt/php@7.4/bin/php

And when I run $ php -v, I’ll see the following output:

PHP 7.4.33 (cli) (built: Jul 13 2023 17:41:11) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies

But if I was to run phpinfo(); within a page hosted via Laravel, I’d get PHP8. This is problematic because if I’m working on a function that I’m eventually going to incorporate in an app that runs in the browser, there may be functionality that doesn’t work as I expect.

As such, it’s important to make sure we have parity between Laravel and our system’s binary. To do this, issue the following command in the terminal:

$ valet use php@7.4
$ valet restart

Obviously, you’ll change the value of php@7.4 to whatever you want to use on your machine. Whatever it is, though, make sure there’s parity between the two. This way, whenever you run a script independently, then you’ll have the same results in the browser as you do in your terminal.

References

Being a Software Developer | Tom McFarlin

Being a Software Developer

Not everyone who works in software development has a degree in computer science (or a degree at all), and I’m not suggesting that you should. However, if you have ever…
Keeping-a-Lock-On-Digital-Security-in-Your-Online-Website-and-Business-computer

The Future of Hacking and How to Stay Secure

Hacking has undergone significant evolution over the decades, transitioning from early pranks to sophisticated cyberattacks that pose threats to both individuals and businesses. Notable groups like the LockBit and BianLian…
joomla-4-web-hosting-fastdot

How to Integrate Joomla with Third-Party APIs?

Joomla is a popular Content Management System (CMS) used for creating and managing websites. It is an open-source platform that offers various features and extensions for customization. Third-party APIs, on…
Being a Software Developer | Tom McFarlin

Being a Software Developer

Not everyone who works in software development has a degree in computer science (or a degree at all), and I’m…
Web Design