Skip to content

Commit 8ca634f

Browse files
committed
Update symfony sqs example
1 parent ac7e788 commit 8ca634f

28 files changed

+2927
-1528
lines changed

Symfony/sqs/.env

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
# Real environment variables win over .env files.
1010
#
1111
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12+
# https://symfony.com/doc/current/configuration/secrets.html
1213
#
1314
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
1415
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
1516

1617
###> symfony/framework-bundle ###
1718
APP_ENV=dev
18-
APP_SECRET=b6c23ba8613e2c2c4d55569d5db70e0c
19-
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
20-
#TRUSTED_HOSTS='^localhost|example\.com$'
19+
APP_SECRET=f5eb653e490a0f834b49cbf95f061e81
2120
###< symfony/framework-bundle ###
2221

23-
# Use a syncronous queue as default locally
24-
MESSENGER_TRANSPORT_DSN=sync://
25-
26-
# Development values
27-
AWS_REGION=foo-region
22+
###> symfony/messenger ###
23+
# Choose one of the transports below
24+
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
25+
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
26+
# MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
27+
###< symfony/messenger ###

Symfony/sqs/.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.serverless
1+
22
###> symfony/framework-bundle ###
33
/.env.local
44
/.env.local.php
@@ -8,3 +8,7 @@
88
/var/
99
/vendor/
1010
###< symfony/framework-bundle ###
11+
12+
###> bref/symfony-bridge ###
13+
/.serverless/
14+
###< bref/symfony-bridge ###
File renamed without changes.

Symfony/sqs/bin/console

+7-32
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,15 @@
33

44
use App\Kernel;
55
use Symfony\Bundle\FrameworkBundle\Console\Application;
6-
use Symfony\Component\Console\Input\ArgvInput;
7-
use Symfony\Component\ErrorHandler\Debug;
86

9-
if (false === in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
10-
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL;
7+
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
8+
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
119
}
1210

13-
set_time_limit(0);
11+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
1412

15-
require dirname(__DIR__).'/vendor/autoload.php';
13+
return function (array $context) {
14+
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
1615

17-
if (!class_exists(Application::class)) {
18-
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
19-
}
20-
21-
$input = new ArgvInput();
22-
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
23-
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
24-
}
25-
26-
if ($input->hasParameterOption('--no-debug', true)) {
27-
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
28-
}
29-
30-
require dirname(__DIR__).'/config/bootstrap.php';
31-
32-
if ($_SERVER['APP_DEBUG']) {
33-
umask(0000);
34-
35-
if (class_exists(Debug::class)) {
36-
Debug::enable();
37-
}
38-
}
39-
40-
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
41-
$application = new Application($kernel);
42-
$application->run($input);
16+
return new Application($kernel);
17+
};

Symfony/sqs/bin/consumer.php

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php declare(strict_types=1);
22

3-
use Bref\Messenger\Sqs\SqsConsumer;
3+
use App\Kernel;
4+
use Bref\Symfony\Messenger\Service\Sqs\SqsConsumer;
5+
use Symfony\Component\Dotenv\Dotenv;
46

5-
require dirname(__DIR__) . '/config/bootstrap.php';
7+
require dirname(__DIR__).'/vendor/autoload.php';
68

7-
lambda(function ($event) {
8-
$kernel = new \App\Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
9-
$kernel->boot();
9+
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
1010

11-
$sqsConsumer = $kernel->getContainer()->get(SqsConsumer::class);
12-
$sqsConsumer->consumeLambdaEvent($event);
13-
});
11+
$kernel = new Kernel($_SERVER['APP_ENV'], (bool)$_SERVER['APP_DEBUG']);
12+
$kernel->boot();
13+
14+
return $kernel->getContainer()->get(SqsConsumer::class);

Symfony/sqs/composer.json

+16-12
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,29 @@
22
"type": "project",
33
"license": "proprietary",
44
"require": {
5-
"php": "^7.1.3",
5+
"php": ">=8.0",
66
"ext-ctype": "*",
77
"ext-iconv": "*",
8-
"bref/bref": "^0.5.12",
9-
"bref/symfony-messenger-sqs": "^0.2.0",
10-
"symfony/console": "4.4.*",
8+
"bref/bref": "^2.0",
9+
"bref/symfony-bridge": "^0.2.1",
10+
"bref/symfony-messenger": "^0.5.4",
11+
"symfony/console": "5.4.*",
12+
"symfony/dotenv": "5.4.*",
1113
"symfony/flex": "^1.3.1",
12-
"symfony/framework-bundle": "4.4.*",
13-
"symfony/messenger": "4.4.*",
14-
"symfony/yaml": "4.4.*"
15-
},
16-
"require-dev": {
17-
"symfony/dotenv": "4.4.*"
14+
"symfony/framework-bundle": "5.4.*",
15+
"symfony/messenger": "5.4.*",
16+
"symfony/runtime": "5.4.*",
17+
"symfony/yaml": "5.4.*"
1818
},
1919
"config": {
2020
"preferred-install": {
2121
"*": "dist"
2222
},
23-
"sort-packages": true
23+
"sort-packages": true,
24+
"allow-plugins": {
25+
"symfony/flex": true,
26+
"symfony/runtime": true
27+
}
2428
},
2529
"autoload": {
2630
"psr-4": {
@@ -58,7 +62,7 @@
5862
"extra": {
5963
"symfony": {
6064
"allow-contrib": false,
61-
"require": "4.4.*"
65+
"require": "5.4.*"
6266
}
6367
}
6468
}

0 commit comments

Comments
 (0)