Skip to content

Commit e679c24

Browse files
committed
Fixed composer related issues.
1 parent e6f9bc1 commit e679c24

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"autoload": {
2222
"psr-4": {
23-
"MyCloud\\": "mycloudth/rest-api-sdk-php/lib/MyCloud"
23+
"MyCloud\\": "lib/MyCloud"
2424
}
2525
}
2626
}

examples/bootstrap.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
11
<?php
22

3-
$vendorPath = dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'vendor';
4-
$composerAutoload = $vendorPath . DIRECTORY_SEPARATOR . 'autoload.php';
3+
function root_dir( $dir, $levels ) {
4+
if ( $levels == 0 ) {
5+
return $dir;
6+
} else {
7+
return root_dir( dirname($dir), --$levels );
8+
}
9+
}
510

611
$reason = '';
712
$loadable = TRUE;
8-
if ( ! file_exists($vendorPath) ) {
9-
$loadable = FALSE;
10-
$reason = "The 'vendor' folder is missing. (expected at '" . $vendorPath . "')";
11-
}
13+
14+
// First, we will assume that this is a standard composer distribution and
15+
// look for the autoload.php in that context...
16+
$topDir = root_dir( __FILE__, 2 );
17+
print "1) Path[top] '" . $topDir . "'" . PHP_EOL;
18+
$composerAutoload = $topDir . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
1219
if ( ! file_exists($composerAutoload) ) {
13-
$loadable = FALSE;
14-
$reason = "The 'autoload.php' file is missing. (expected at '" . $composerAutoload . "')";
20+
print " '" . $composerAutoload . "' NOT FOUND". PHP_EOL;
21+
$topDir = root_dir( __FILE__, 1 );
22+
print "2) Path[top] '" . $topDir . "'" . PHP_EOL;
23+
$composerAutoload = $topDir . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
24+
if ( ! file_exists($composerAutoload) ) {
25+
$loadable = FALSE;
26+
$reason = "The 'autoload.php' file was not found. (expected at '" . $composerAutoload . "')";
27+
}
1528
}
1629

1730
if ( $loadable ) {
31+
"Loading: '" . $composerAutoload . "'" . PHP_EOL;
1832
require $composerAutoload;
1933
} else {
2034
print "Could not bootstrap the example program:" . PHP_EOL;

0 commit comments

Comments
 (0)