LoginSignup
0
0

More than 5 years have passed since last update.

Laravel5やLumen でartisanが "Cannot redeclare class Event" で起動できないときの対応

Posted at

事象

Laravel5|Lumenで、

% laravel new testapp

または、

% lumen new testapp

として、まっさらなプロジェクトを作成して、さて既定のWelcomeな画面確認すっかという時に、

% cd testapp
% php artisan serve



  [ErrorException]              
  Cannot redeclare class Event  


とエラーが出て怒られた。Event クラスを再宣言するな、と。
ローカル環境のMacで発生し、そのゲストOSのFedora 23 上で再現しなかった。

原因

同志を探したところ、原因は、こういうことらしい。
http://laravel.io/forum/05-14-2015-cant-run-artisan-in-lumen

You have the php_event pecl extension installed

なるほど、php_event のエクステンションと、Laravel|Lumen でクラス名が衝突している、と。
考え無しに使うかどうかわからんモジュールを何でもかんでもワイルドカードで入れるからこうなる。

対応

以下で対応。
あらためて、環境は、
OS : Mac OS X 10.10.5(Yosemite)
PHP : 5.6.15 (brew install php56 でインストール。phpenv未使用)

brew remove php56-event
rm /usr/local/etc/php/5.6/conf.d/ext-event.ini

再度、artisanの動作確認。

% php artisan serve
Lumen development server started on http://localhost:8000/

動いた。

教訓

  • 名前空間重点
  • エクステンションだのモジュールだのライブラリだのは必要であることを確認してから入れろ
  • ローカル環境の管理しっかりしろ
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