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

Update symfony examples #43

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions Symfony/sqs/.env
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
# https://symfony.com/doc/current/configuration/secrets.html
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

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

# Use a syncronous queue as default locally
MESSENGER_TRANSPORT_DSN=sync://

# Development values
AWS_REGION=foo-region
###> symfony/messenger ###
# Choose one of the transports below
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
# MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
###< symfony/messenger ###
6 changes: 5 additions & 1 deletion Symfony/sqs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.serverless

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
Expand All @@ -8,3 +8,7 @@
/var/
/vendor/
###< symfony/framework-bundle ###

###> bref/symfony-bridge ###
/.serverless/
###< bref/symfony-bridge ###
File renamed without changes.
39 changes: 7 additions & 32 deletions Symfony/sqs/bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,15 @@

use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\ErrorHandler\Debug;

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

set_time_limit(0);
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

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

if (!class_exists(Application::class)) {
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}

$input = new ArgvInput();
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
}

if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}

require dirname(__DIR__).'/config/bootstrap.php';

if ($_SERVER['APP_DEBUG']) {
umask(0000);

if (class_exists(Debug::class)) {
Debug::enable();
}
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);
return new Application($kernel);
};
17 changes: 9 additions & 8 deletions Symfony/sqs/bin/consumer.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php declare(strict_types=1);

use Bref\Messenger\Sqs\SqsConsumer;
use App\Kernel;
use Bref\Symfony\Messenger\Service\Sqs\SqsConsumer;
use Symfony\Component\Dotenv\Dotenv;

require dirname(__DIR__) . '/config/bootstrap.php';
require dirname(__DIR__).'/vendor/autoload.php';

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

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

return $kernel->getContainer()->get(SqsConsumer::class);
28 changes: 16 additions & 12 deletions Symfony/sqs/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"php": ">=8.0",
"ext-ctype": "*",
"ext-iconv": "*",
"bref/bref": "^0.5.12",
"bref/symfony-messenger-sqs": "^0.2.0",
"symfony/console": "4.4.*",
"bref/bref": "^2.0",
"bref/symfony-bridge": "^0.2.1",
"bref/symfony-messenger": "^0.5.4",
"symfony/console": "5.4.*",
"symfony/dotenv": "5.4.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "4.4.*",
"symfony/messenger": "4.4.*",
"symfony/yaml": "4.4.*"
},
"require-dev": {
"symfony/dotenv": "4.4.*"
"symfony/framework-bundle": "5.4.*",
"symfony/messenger": "5.4.*",
"symfony/runtime": "5.4.*",
"symfony/yaml": "5.4.*"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"symfony/flex": true,
"symfony/runtime": true
}
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -58,7 +62,7 @@
"extra": {
"symfony": {
"allow-contrib": false,
"require": "4.4.*"
"require": "5.4.*"
}
}
}
Loading