1

How is it that php-ast is listed in phpinfo() but not when running $ php -m to list modules?

Working on installing phan, the static analyzer. I use MAMP Pro and have verified that $ which php returns the desired php version within MAMP. I have updated the php.ini file, and running phpinfo() displays AST as expected.

When I run vendor/bin/phan without the flag, I still get the warning that AST should be installed.

I have run it once with the flag to use the polypill parser, and phan works as expected.

enter image description here

enter image description here

Note: Answers elsewhere using --with-config-file-path don't seem to be working for me as I get a list of valid PHP console commands and it is not one of them: PHP module is shown in phpinfo(), but not php -m

1 Answer 1

0

My best guess is that you need to install the ast extension first.

What I did is this

  1. Install PEAR following the instructions in this post

It's basically two commands

curl -O https://pear.php.net/go-pear.phar
sudo php -d detect_unicode=0 go-pear.phar

Note that I have updated the URL to use https

I've simply acknowledged the default config during installation of PEAR, hoping that it will not disturb MAMP in normal operation to have some extra directories.

  1. Download ast from pecl.php.net, since I couldn't make pecl install ast work, maybe it works for you. Then you'll need to run sudo pear install [path-to-downloaded-ast.tgz], replacing the file path with your download location.

  2. Edit php.ini like you already did, adding the extension.

Result should be this

$ php -m

[PHP Modules]
ast
...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.