File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33This change log references the repository changes and releases, which respect [ semantic versioning] ( https://semver.org ) .
44
5- ## v2.0.1
5+ ## v2.1.0
6+
7+ ### New features
8+
9+ 1 . [ AutoloadDetector.php] ( ../tools/cli-toolkit/Classes/AutoloadDetector.php ) is added for
10+ [ init.php] ( ../tools/cli-toolkit/init.php ) .
11+
12+ Previously all built-in scripts ([ cli-toolkit] ( ../tools/cli-toolkit ) ) could not be launched without calling
13+ ` composer install ` additionally inside the library directory.
14+ And from now on your main project's ` vendor/autoload.php ` path should be detectable.
615
716### Patches
817
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace MagicPush \CliToolkit \Tools \CliToolkit \Classes ;
6+
7+ class AutoloadDetector {
8+ public static function detectAndRequire (): void {
9+ $ currentDirPath = __DIR__ ;
10+ $ detectedPath = null ;
11+ while (true ) {
12+ $ autoloaderPath = $ currentDirPath . '/vendor/autoload.php ' ;
13+ if (file_exists ($ autoloaderPath )) {
14+ require_once $ autoloaderPath ;
15+
16+ return ;
17+ }
18+
19+ $ previousDirPath = $ currentDirPath ;
20+ $ currentDirPath = dirname ($ previousDirPath );
21+ // We can't go higher than a filesystem's top:
22+ if ($ currentDirPath === $ previousDirPath ) {
23+ return ;
24+ }
25+ }
26+ }
27+ }
Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5- require_once __DIR__ . '/../../vendor/autoload.php ' ;
5+ use MagicPush \CliToolkit \Tools \CliToolkit \Classes \AutoloadDetector ;
6+
7+ require_once __DIR__ . '/Classes/AutoloadDetector.php ' ;
8+
9+ AutoloadDetector::detectAndRequire ();
610
711mb_internal_encoding ('UTF-8 ' );
812setlocale (LC_ALL , 'en_US.UTF-8 ' );
You can’t perform that action at this time.
0 commit comments