avatar

麦兜的小站

MDO.INK

  • 首页
  • 随笔
  • 知识库
  • 归档
  • 动态
  • 标签
  • 关于
Home How to set up PHP7.4 on MacOS.
文章

How to set up PHP7.4 on MacOS.

Posted 28 days ago Updated 28 days ago
By power 已删除用户
4~5 min read

This is all very well and good. Apart from one small insignificant thing…

The version of PHP in use is currently 7.4.

This means that we must install the specific version of PHP on a Mac. This is where the difficulties lie.

Setting up PHP on MacOS. I initially used the command

brew install php

This command did install PHP on my machine. Unfortunately, the command

brew install php7.4

does not install version 7.4. it actually returns a warning which can be shown below.

Warning: No available formula with the name "[email protected]". Did you mean [email protected] or [email protected]?

To correctly install PHP7.4 on a MacOS then follow the below snippets and save yourself plenty of heartache!

First, we need to add a new tap to homebrew which provides formulas for the different PHP versions including PHP 7.4 (which we need).

brew tap shivammathur/php

Second, once this tap has been added correctly. We can then install PHP7.4 which can be done using the below command.

brew install shivammathur/php/[email protected]

Third, once the above command ran successfully. We can change the version of PHP used on our machine with the below command.

brew install shivammathur/php/[email protected]

Lastly, we need to add this to our path from the local terminal with the below commands.

echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc  
echo 'export PATH="/opt/homebrew/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc

Finally, to confirm the correct version of PHP is in use locally we run the command.

php -v

Hopefully, this article saves a lot of people a lot of soul searching in their early days as a developer in the PHP world!

知识库
License:  CC BY 4.0
Share

Further Reading

Jul 31, 2025

如何实现接口幂等性

通俗的说,用户在系统中有操作,不管重复多少次,都应该产生一样的效果或返回一样的结果的。 幂等性的概念 幂等(Idempotent)是一个数学与计算机学的概念,常见于抽象代数中。 f(n)=1^n//无...

Jul 19, 2025

10个npm工具包

有了npm之后,前端人员真的是过上好日子了。我们可以直接把别人写好的工具包拿来用,非常的方便。 1.day.js-轻量日期处理 npminstalldayjs importdayjsfrom'd...

Jul 17, 2025

How to set up PHP7.4 on MacOS.

Thisisallverywellandgood.Apartfromonesmallinsignificantthing… TheversionofPHPinuseiscurrently7.4. Th...

OLDER

Automa:一键自动化,网页数据采集与工作流程优化专家Automa:解锁自动化

NEWER

10个npm工具包

Recently Updated

  • 如何实现接口幂等性
  • 10个npm工具包
  • How to set up PHP7.4 on MacOS.
  • Automa:一键自动化,网页数据采集与工作流程优化专家Automa:解锁自动化
  • Mac 下用 brew 搭建 LNMP

Trending Tags

thinkphp clippings

Contents

©2025 麦兜的小站. Some rights reserved.

Using the Halo theme Chirpy