-
|
Description: I'm trying to run symfony "bin/console" command like described in documentation. How to reproduce: aws lambda invoke \
--function-name PhpCliLambdaName \
--region us-east-1 \
--cli-binary-format raw-in-base64-out \
--payload '"d:s:u --dump-sql"' \
response.jsonreturns {
"StatusCode": 200,
"FunctionError": "Unhandled",
"ExecutedVersion": "$LATEST"
}and logs this CDK package.json "@bref.sh/constructs": "^1.0.0",brefStack.ts this.fpm = new PhpFpmFunction(this, 'PhpFpm', {
code,
handler: 'public/index.php',
timeout: Duration.seconds(20),
...lambdaProps,
});
this.cli = new ConsoleFunction(this, 'PhpCli', {
code,
handler: 'bin/console',
timeout: Duration.seconds(120),
...lambdaProps, // contains architecture, environment, role, securityGroups, vpc and vpcSubnets
});Symfony - code composer.json (symfony 6.3) "bref/bref": "^2.0",
"bref/symfony-bridge": "0.2.1",
"symfony/runtime": "6.3.*"bin/console #!/usr/bin/env php
<?php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
return new Application($kernel);
};I've already tried to send payload as json object with APP_ENV, APP_DEBUG, but in this case I'm not able to figure out how should I provide command. I was able to execute command with modified #!/usr/bin/env php
<?php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$input = new Symfony\Component\Console\Input\ArrayInput($context);
$output = new Symfony\Component\Console\Output\BufferedOutput();
$application->run($input, $output);
return new Symfony\Component\HttpFoundation\Response($output->fetch());
};Looking at ConsoleRuntime I'm clearly missing "event". But how can I provide it? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
It seems like you have modified You should leave this file like on any standard Symfony installation, the "console" runtime takes care of executing it. |
Beta Was this translation helpful? Give feedback.
-
|
Figured it out. The problem is that |
Beta Was this translation helpful? Give feedback.
Ohhh thanks for investigating further! It seems related to brefphp/constructs#4, which I can't reproduce for some reason! I need to figure this out 🤔