function GenerateAutoloadRuntimeReferenceFile::generateAutoloadRuntime
Same name and namespace in other branches
- 11.x composer/Plugin/Scaffold/GenerateAutoloadRuntimeReferenceFile.php \Drupal\Composer\Plugin\Scaffold\GenerateAutoloadRuntimeReferenceFile::generateAutoloadRuntime()
Generates the autoload_runtime file at the specified location.
This only writes a bit of PHP that includes the autoload_runtime file that Composer generated. Drupal does this so that it can guarantee that there will always be an `autoload_runtime.php` file in a well-known location.
Parameters
\Composer\IO\IOInterface $io: IOInterface to write to.
string $package_name: The name of the package defining the autoload_runtime file (the root package).
string $web_root: The path to the web root.
string $vendor: The path to the vendor directory.
Return value
\Drupal\Composer\Plugin\Scaffold\Operations\ScaffoldResult The result of the autoload_runtime file generation.
1 call to GenerateAutoloadRuntimeReferenceFile::generateAutoloadRuntime()
- Handler::scaffold in composer/
Plugin/ Scaffold/ Handler.php - Copies all scaffold files from source to destination.
File
-
composer/
Plugin/ Scaffold/ GenerateAutoloadRuntimeReferenceFile.php, line 42
Class
- GenerateAutoloadRuntimeReferenceFile
- Generates an 'autoload_runtime.php' that includes the Symfony_runtime loader.
Namespace
Drupal\Composer\Plugin\ScaffoldCode
public static function generateAutoloadRuntime(IOInterface $io, string $package_name, string $web_root, string $vendor) : ScaffoldResult {
$autoload_runtime_path = static::autoloadRuntimePath($package_name, $web_root);
// Calculate the relative path from the webroot (location of the project
// autoload_runtime.php) to the vendor directory.
$fs = new Filesystem();
$relative_autoload_path = $fs->findShortestPath($autoload_runtime_path->fullPath(), "{$vendor}/autoload_runtime.php");
file_put_contents($autoload_runtime_path->fullPath(), static::autoLoadRuntimeContents($relative_autoload_path));
return new ScaffoldResult($autoload_runtime_path, TRUE);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.