LoginSignup
3
3

More than 5 years have passed since last update.

CLIコマンドはautoload.phpをどのように探せばよいのか

Posted at

phpunitでは、autoload.phpを以下の3か所から探している。

  • __DIR__ . '/../../autoload.php'
  • __DIR__ . '/../vendor/autoload.php'
  • __DIR__ . '/vendor/autoload.php'

foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
    if (file_exists($file)) {
        define('PHPUNIT_COMPOSER_INSTALL', $file);

        break;
    }
}

ざっくりいうと、普通にインストールしたとき用と、composer.jsonでbin-dirbinにしたとき用と、あとは開発時用みたいなことなんだけど、細かく言うとcomposer installがbinに対して何をやっているのか、シンボリックリンクが使える場合と使えない場合についての説明が必要なのでそのうち書くかも。

参考:
https://github.com/sebastianbergmann/phpunit/pull/1333

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