LoginSignup
4
3

More than 5 years have passed since last update.

Laravel Homestead(PHP7.2)環境におけるCountable周りのエラー対処方法

Last updated at Posted at 2017-12-22

エラー発生環境

  • Laravel Homestead v6.4.0 以上
  • PHP7.2

エラー内容

ErrorException in Builder.php line 1015:

count(): Parameter must be an array or an object that implements Countable

原因

Counting of non-countable objects

PHP7.2以降、Countableでない値をcount()しようとした場合にwarningが発生するため。

対処方法

Homestead.yaml にPHP7.2以前のバージョンを使用するように設定。
v6.0.0以降でNginxを使用している場合sites 毎にPHPのバージョンを指定可能)

Laravel Homestead 複数のPHPバージョン

sites:
    - map: homestead.test
      to: /path/to/public
      php: "7.0"

設定後に vagrant up --provision で再度プロビジョニングしないと反映されないため注意です。

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