Skip to content

Commit

Permalink
Merge pull request #3343 from grebaldi/bugfix/autoloader-symlink-foo
Browse files Browse the repository at this point in the history
BUGFIX: Discover autoloader from FLOW_ROOTPATH rather than __DIR__
  • Loading branch information
bwaidelich authored Apr 17, 2024
2 parents 6b1efba + b7dd98d commit b77dc09
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Neos.Flow/Scripts/flow.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,6 @@
array_shift($argv);
require(__DIR__ . '/migrate.php');
} else {
$autoloaderPath = dirname(__DIR__, 3) . '/Libraries/autoload.php';
if (!file_exists($autoloaderPath)) {
echo 'Composers "autoload.php" file was not found. The file is expected to be located in the path:' . PHP_EOL . PHP_EOL;
echo $autoloaderPath . PHP_EOL . PHP_EOL;
echo 'This could be due to a missing "config" => "vendor-dir" section of your root "composer.json" file.' . PHP_EOL . PHP_EOL;
echo 'The section key and value should look like the following:' . PHP_EOL;
echo '"vendor-dir": "Packages/Libraries"' . PHP_EOL;
echo 'Update your "composer.json" file accordingly and run the "composer update" command.' . PHP_EOL;
exit(1);
}
$composerAutoloader = require($autoloaderPath);

if (DIRECTORY_SEPARATOR !== '/' && trim(getenv('FLOW_ROOTPATH'), '"\' ') === '') {
$absoluteRootpath = dirname(realpath(__DIR__ . '/../../../'));
if (realpath(getcwd()) === $absoluteRootpath) {
Expand All @@ -65,6 +53,18 @@
$_SERVER['FLOW_ROOTPATH'] = trim(getenv('FLOW_ROOTPATH'), '"\' ') ?: dirname($_SERVER['PHP_SELF']);
}

$autoloaderPath = $_SERVER['FLOW_ROOTPATH'] . '/Packages/Libraries/autoload.php';
if (!file_exists($autoloaderPath)) {
echo 'Composers "autoload.php" file was not found. The file is expected to be located in the path:' . PHP_EOL . PHP_EOL;
echo $autoloaderPath . PHP_EOL . PHP_EOL;
echo 'This could be due to a missing "config" => "vendor-dir" section of your root "composer.json" file.' . PHP_EOL . PHP_EOL;
echo 'The section key and value should look like the following:' . PHP_EOL;
echo '"vendor-dir": "Packages/Libraries"' . PHP_EOL;
echo 'Update your "composer.json" file accordingly and run the "composer update" command.' . PHP_EOL;
exit(1);
}
$composerAutoloader = require($autoloaderPath);

$context = trim((string)\Neos\Flow\Core\Bootstrap::getEnvironmentConfigurationSetting('FLOW_CONTEXT'), '"\' ') ?: 'Development';

$bootstrap = new \Neos\Flow\Core\Bootstrap($context, $composerAutoloader);
Expand Down

0 comments on commit b77dc09

Please sign in to comment.