Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to run Laravel under custom vendor location #131

Merged
merged 22 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/HandlerResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ private function laravel(): Application
return $this->laravel;
}

$bootstrapFile = getcwd() . '/bootstrap/app.php';
// ./vendor/bref/laravel-bridge/src/
$bootstrapFile = __DIR__ . '/../../../../bootstrap/app.php';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use realpath() on both strings?


if (! file_exists($bootstrapFile)) {
throw new RuntimeException(
Expand Down
6 changes: 4 additions & 2 deletions src/bref-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Bref\LaravelBridge\StorageDirectories;

Bref::beforeStartup(static function () {
$laravelHome = __DIR__ . '/../../../../';

if (! defined('STDERR')) {
define('STDERR', fopen('php://stderr', 'wb'));
}
Expand All @@ -26,7 +28,7 @@
return;
}

$defaultConfigCachePath = $_SERVER['LAMBDA_TASK_ROOT'] . '/bootstrap/cache/config.php';
$defaultConfigCachePath = $laravelHome . '/bootstrap/cache/config.php';

if (file_exists($defaultConfigCachePath)) {
return;
Expand All @@ -43,7 +45,7 @@
fwrite(STDERR, "Running 'php artisan config:cache' to cache the Laravel configuration\n");

// 1>&2 redirects the output to STDERR to avoid messing up HTTP responses with FPM
passthru('php artisan config:cache 1>&2');
passthru("php {$laravelHome}artisan config:cache 1>&2");
}
});

Expand Down