-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix autoloader collisions on scoped files
- Loading branch information
1 parent
bf1d39b
commit a28a3cc
Showing
4 changed files
with
43 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* PHP-Scoper also can not handle Composers static file autoloaders. | ||
* This is due to Composer loading files based on a hash which is generated from package name and relative file path. | ||
* For a workaround see #298. https://github.com/humbug/php-scoper/blob/master/docs/limitations.md#composer-autoloader | ||
* | ||
* Script taken from https://github.com/humbug/php-scoper/issues/298#issuecomment-525700081 | ||
* | ||
* This helper is needed to "trick" composer autoloader to load the prefixed files | ||
* Otherwise if a dependency contains the same libraries ( i.e. guzzle ) it won't | ||
* load the files, as the file hash is the same and thus composer would think this was already loaded | ||
* | ||
* More information also found here: https://github.com/humbug/php-scoper/issues/298 | ||
*/ | ||
$composer_path = './vendor-build/composer'; | ||
$static_loader_path = $composer_path . '/autoload_static.php'; | ||
echo "Fixing $static_loader_path \n"; | ||
$static_loader = file_get_contents($static_loader_path); | ||
$static_loader = \preg_replace('/\'([A-Za-z0-9]*?)\' => __DIR__ \. (.*?),/', '\'a$1\' => __DIR__ . $2,', $static_loader); | ||
file_put_contents($static_loader_path, $static_loader); | ||
$files_loader_path = $composer_path . '/autoload_files.php'; | ||
echo "Fixing $files_loader_path \n"; | ||
$files_loader = file_get_contents($files_loader_path); | ||
$files_loader = \preg_replace('/\'(.*?)\' => (.*?),/', '\'a$1\' => $2,', $files_loader); | ||
file_put_contents($files_loader_path, $files_loader); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters