LoginSignup
1
3

More than 5 years have passed since last update.

VS CodeでPHP intellisenseを使おうとしたらPHPモジュールが足りずエラーになった

Last updated at Posted at 2017-11-09
  • Visual Studio Code
  • phpbrew
  • php7.1.4

という感じで最近PHPの開発を行い始めたのですが、Visual Studio Codeの拡張機能PHP intelliseseがどうやらエラーになり全然機能してくれない状態に。

ログを見ると undefined function hogehoge みたいなエラーがたくさん出ていました。
最初に出ていたエラーが undefined function AdvancedJsonRpc\json_decode となっていたので明らかにおかしい。phpbrew、お前か。

$ php -m を実行し、インストールされているモジュールを確認したところやはりjson関連のモジュールが入っていませんでした。という訳でインストール。

$ phpbrew ext install json

よっしゃーこれで解決!と思ったら、他にも足りないモジュールがあるようでまたエラーが…

結局json以外にctypefilterの二つも追加でインストールする必要があったのでインストールを実行。

$ phpbrew ext install ctype
$ phpbrew ext install filter

モジュール群を再度確認。

ryosukes ~ $ php -m
[PHP Modules]
Core
ctype
date
dom
filter
json
libxml
openssl
pcre
Phar
Reflection
session
SimpleXML
SPL
standard
tokenizer
xml
xmlreader
xmlwriter
xsl
zlib

[Zend Modules]

VS Codeを再起動し解決。快適になりました。

追記

コメントにてご指摘ただきましたが、phpbrewでインストールする際、#variantsの指定がなかったため、個人環境に標準的なモジュールが入っていなかったようでした。

なので、phpbrewでphpをインストールする際には標準的なモジュールを入れてくれる +default というvariantを指定してインストールし直してやればよりよくなります。

$ phpbrew remove php-7.1.4
$ phpbrew install 7.1.4 +default

公式で推奨されてますね。
https://github.com/phpbrew/phpbrew#starting-building-your-own-php

1
3
2

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
1
3