forked from coenjacobs/mozart
-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathbootstrap.php
More file actions
43 lines (40 loc) · 1.76 KB
/
bootstrap.php
File metadata and controls
43 lines (40 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* When strauss is installed via Composer, this will help load the aliases file.
*
* When `composer install --no-dev` is run, Strauss won't be installed and this file won't exist to load
* `autoload_aliases.php`. This is good – we don't want to load the aliases file in production or we end up
* fixing the namespace collision issue for ourselves but preserving it for other packages.
*
* This file tries to read the project composer.json file to find the target directory. If it can't find it, it
* assumes the default "vendor-prefixed".
*
* @package brianhenryie/strauss
*/
$autoloadAliasesFilepath = realpath(__DIR__ . '/../../composer/autoload_aliases.php');
if (file_exists($autoloadAliasesFilepath)) {
$targetDirectoryFromComposerExtra = function () {
$composerJsonFilepath = realpath(__DIR__ . '/../../../composer.json');
if (file_exists($composerJsonFilepath)) {
$composerJson = json_decode(file_get_contents($composerJsonFilepath), true);
if (isset($composerJson['extra']['strauss']['target_directory'])
&&
is_dir(realpath(__DIR__ . '/../../../'.$composerJson['extra']['strauss']['target_directory']))
) {
return $composerJson['extra']['strauss']['target_directory'];
}
}
return null;
};
$autoloadTargetFilepath = sprintf(
"%s/%s/autoload.php",
getcwd(),
$targetDirectoryFromComposerExtra() ?? "vendor-prefixed"
);
if ($autoloadTargetFilepath !== realpath(__DIR__ . '/../../autoload.php') && file_exists($autoloadTargetFilepath)) {
require_once $autoloadTargetFilepath;
}
unset($autoloadTargetFilepath);
require_once $autoloadAliasesFilepath;
}
unset($autoloadAliasesFilepath,);