Skip to content

Commit 0cf4816

Browse files
committed
Merge pull request #156 from hason/bin
The correct registration of binary script for composer
2 parents 2893b09 + e9afc12 commit 0cf4816

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

bin/phpcr

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
#!/usr/bin/env php
22
<?php
33

4-
$vendorDir = __DIR__.'/../vendor';
5-
6-
$file = $vendorDir.'/autoload.php';
7-
if (file_exists($file)) {
8-
$autoload = require_once $file;
9-
} else {
10-
die("Install dependencies before using this command.\n");
4+
if (!class_exists('\Symfony\Component\Console\Application')) {
5+
if (is_file(__DIR__.'/../vendor/autoload.php')) {
6+
require __DIR__.'/../vendor/autoload.php';
7+
} elseif (is_file(__DIR__.'/../../../autoload.php')) {
8+
require __DIR__.'/../../../autoload.php';
9+
} else {
10+
echo 'Cannot find the vendor directory, have you executed composer install?'.PHP_EOL;
11+
echo 'See https://getcomposer.org to get Composer.'.PHP_EOL;
12+
exit(1);
13+
}
1114
}
1215

1316
$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"PHPCR\\Util": "src"
4040
}
4141
},
42+
"bin": ["bin/phpcr"],
4243
"extra": {
4344
"branch-alias": {
4445
"dev-master": "1.2-dev"

0 commit comments

Comments
 (0)