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 deployments in sub directory #69

Merged
merged 2 commits into from
Aug 27, 2024
Merged

Conversation

Nyholm
Copy link
Collaborator

@Nyholm Nyholm commented Aug 27, 2024

Correct me if Im wrong. But I dont think it is possible to use this bridge if you deployed your application in a sub-directory. That is because we give the BrefRuntime the wrong "project_dir".

My serverless.yaml includes the following:

provider:
    name: aws
    environment:
        BREF_AUTOLOAD_PATH: '/var/task/app/vendor/autoload.php'
        BREF_LOOP_MAX: 100
        APP_ENV: prod

I cannot add the LAMBDA_TASK_ROOT environment variable because of AWS does not allow me. I solve this by not relying on that env var to find the project root. Instead I do $options['project_dir'] = dirname(__DIR__, 4); which is very similar to what the default autoload_runtime.php does.

$runtime = $_SERVER['APP_RUNTIME'] ?? $_ENV['APP_RUNTIME'] ?? 'Symfony\\Component\\Runtime\\SymfonyRuntime';
$runtime = new $runtime(($_SERVER['APP_RUNTIME_OPTIONS'] ?? $_ENV['APP_RUNTIME_OPTIONS'] ?? []) + [
  'project_dir' => dirname(__DIR__, 1),
]);

Copy link
Member

@mnapoli mnapoli left a comment

Choose a reason for hiding this comment

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

LGTM, I can merge on the build is green

@Nyholm
Copy link
Collaborator Author

Nyholm commented Aug 27, 2024

Thank you for the review. The PR is updated and CI is green

@mnapoli
Copy link
Member

mnapoli commented Aug 27, 2024

🤦 sorry forgot about this one, we'll have another release 😅

@mnapoli mnapoli merged commit 5b1f650 into brefphp:master Aug 27, 2024
7 checks passed
@Nyholm
Copy link
Collaborator Author

Nyholm commented Aug 27, 2024

Thank you for merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants