0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【macOS】asdfを使ってphpを導入するには

Posted at

mac に asdf を使って php を導入する奮闘記

WSLでの使い方は以下の通り

asdf の導入からエラーまで

mac だとなんか brew にあるみたいなので、こちらからインストールしてみる
※ちなみに当方 Intel Mac

$ brew install asdf
$ asdf --version
version: v0.14.1

$ asdf plugin-add php https://github.com/asdf-community/asdf-php.git
Plugin named php already added

ありゃ、すでにPHPプラグインが入ってた

$ asdf install php 8.3.12

数々のエラーが出てきた...
検索用に並べておく

configure: error: bison 3.0.0 or later is required to generate PHP parsers (excluded versions: none).

configure: error: re2c 1.0.3 is required to generate PHP lexers.

configure: error: The pkg-config script could not be found or is too old.  Make sure it

No package 'gdlib' found

configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>

If you need to have libiconv first in your PATH,

No package 'oniguruma' found

No package 'libzip' found

Could not open input file: composer-setup.php

あ〜わかんねぇ〜
ということで調べたところ、有用 issue を見つけた

$ brew install libsodium gpg git tmux neovim vim htop curl wget re2c bison zlib libgd libiconv oniguruma postgresql bzip2 readline libedit tidy-html5 openssl libzip

$ export PATH="$(brew --prefix bison)/bin:$(brew --prefix icu4c)/bin:$(brew --prefix icu4c)/sbin:$PATH"
$ export PHP_CONFIGURE_OPTIONS="--with-zlib-dir=$(brew --prefix zlib) --with-bz2=$(brew --prefix bzip2) --with-readline=$(brew --prefix readline) --with-libedit=$(brew --prefix libedit) --with-tidy=$(brew --prefix tidy-html5) --with-iconv=$(brew --prefix libiconv) --with-openssl=$(brew --prefix openssl) --with-curl=$(brew --prefix curl)"

$ asdf install php 8.3.12
$ asdf global php 8.3.12

$ php --version
PHP 8.3.12 (cli) (built: Oct  5 2024 21:08:45) (NTS)
$ composer --version
Composer version 2.8.1 2024-10-04 11:31:01
PHP version 8.3.12 

お〜一発で成功
brew で必要なパッケージを導入していたが、PATHとかの設定を忘れてたみたい
流石にビルドまでは精通してない...かなしみ...

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?