Skip to content

Commit ffd1c45

Browse files
committed
Fix Composer autoload path in examples
If php-cli-tools added in some project using `composer require wp-cli/php-cli-tools` then examples scripts will not work because path to `/vendor/autoload.php` will be different from path used in `/examples/common.php`.
1 parent 5311a4b commit ffd1c45

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

examples/common.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
ini_set('log_errors', 0);
1010
ini_set('html_errors', 0);
1111

12-
require_once __DIR__ . '/../vendor/autoload.php';
12+
foreach(array(__DIR__ . '/../vendor', __DIR__ . '/../../../../vendor') as $vendorDir) {
13+
if(is_dir($vendorDir)) {
14+
require_once $vendorDir . '/autoload.php';
15+
break;
16+
}
17+
}
1318

1419
function test_notify(cli\Notify $notify, $cycle = 1000000, $sleep = null) {
1520
for ($i = 0; $i <= $cycle; $i++) {

0 commit comments

Comments
 (0)