Skip to content
This repository was archived by the owner on Jan 6, 2020. It is now read-only.

Commit 257ee2e

Browse files
committed
Allow building bootstrap.php.cache when app/autoload.php is absent
If app/autoload.php is absent then use the autoload.php in Composer's vendor directory.
1 parent 1784668 commit 257ee2e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Composer/ScriptHandler.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ public static function buildBootstrap(Event $event)
7575
return;
7676
}
7777
}
78+
79+
if (!static::useSymfonyAutoloader($options)) {
80+
$autoloadDir = $options['vendor-dir'];
81+
}
82+
7883
if (!static::hasDirectory($event, 'symfony-app-dir', $autoloadDir, 'build bootstrap file')) {
7984
return;
8085
}
@@ -377,6 +382,7 @@ protected static function getOptions(Event $event)
377382
$options['symfony-cache-warmup'] = getenv('SYMFONY_CACHE_WARMUP') ?: $options['symfony-cache-warmup'];
378383

379384
$options['process-timeout'] = $event->getComposer()->getConfig()->get('process-timeout');
385+
$options['vendor-dir'] = $event->getComposer()->getConfig()->get('vendor-dir');
380386

381387
return $options;
382388
}
@@ -453,4 +459,16 @@ protected static function useNewDirectoryStructure(array $options)
453459
{
454460
return isset($options['symfony-var-dir']) && is_dir($options['symfony-var-dir']);
455461
}
462+
463+
/**
464+
* Returns true if the application bespoke autoloader is used.
465+
*
466+
* @param array $options Composer options
467+
*
468+
* @return bool
469+
*/
470+
protected static function useSymfonyAutoloader(array $options)
471+
{
472+
return isset($options['symfony-app-dir']) && is_file($options['symfony-app-dir'].'/autoload.php');
473+
}
456474
}

0 commit comments

Comments
 (0)