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

Symfony - persistent connections #5045

Merged
merged 2 commits into from
Sep 9, 2019
Merged
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
5 changes: 3 additions & 2 deletions frameworks/PHP/symfony/config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.7'
server_version: '8.0'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci

options:
!php/const \PDO::ATTR_PERSISTENT: true
url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: true
Expand Down
4 changes: 2 additions & 2 deletions frameworks/PHP/symfony/src/Controller/DbController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function db(): JsonResponse
*/
public function queries(Request $request): JsonResponse
{
$queries = $request->query->getInt('queries', 1);
$queries = (int) $request->query->get('queries', 1);
$queries = min(max($queries, 1), 500);

// possibility for enhancement is the use of SplFixedArray -> http://php.net/manual/de/class.splfixedarray.php
Expand All @@ -54,7 +54,7 @@ public function queries(Request $request): JsonResponse
*/
public function update(Request $request): JsonResponse
{
$queries = $request->query->getInt('queries', 1);
$queries = (int) $request->query->get('queries', 1);
$queries = min(500, max(1, $queries));

$worlds = [];
Expand Down
4 changes: 2 additions & 2 deletions frameworks/PHP/symfony/src/Controller/DbRawController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function db(): JsonResponse
*/
public function queries(Request $request): JsonResponse
{
$queries = $request->query->getInt('queries', 1);
$queries = (int) $request->query->get('queries', 1);
$queries = min(max($queries, 1), 500);

// possibility for enhancement is the use of SplFixedArray -> http://php.net/manual/de/class.splfixedarray.php
Expand All @@ -55,7 +55,7 @@ public function queries(Request $request): JsonResponse
*/
public function updates(Request $request): JsonResponse
{
$queries = $request->query->getInt('queries', 1);
$queries = (int) $request->query->get('queries', 1);
$queries = min(500, max(1, $queries));

$worlds = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(Environment $twig, FortuneRepository $fortuneReposit
*/
public function fortunes(): Response
{
$fortunes = $this->fortuneRepository->findAll();
$fortunes = $this->fortuneRepository->findBy([]);

$runtimeFortune = new Fortune();
$runtimeFortune->setId(0);
Expand Down
5 changes: 5 additions & 0 deletions frameworks/PHP/symfony/symfony-raw.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ WORKDIR /symfony
RUN mkdir -m 777 -p /symfony/var/cache/{dev,prod} /symfony/var/log
RUN COMPOSER_ALLOW_SUPERUSER=1 composer install --classmap-authoritative --no-dev
RUN COMPOSER_ALLOW_SUPERUSER=1 composer dump-env prod

# removes hardcoded option `ATTR_STATEMENT_CLASS` conflicting with `ATTR_PERSISTENT`. Hack not needed when upgrading to Doctrine 3
# see https://github.com/doctrine/dbal/issues/2315
RUN sed -i '/PDO::ATTR_STATEMENT_CLASS/d' ./vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php

RUN php bin/console cache:clear

CMD service php7.3-fpm start && \
Expand Down
5 changes: 5 additions & 0 deletions frameworks/PHP/symfony/symfony.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ WORKDIR /symfony
RUN mkdir -m 777 -p /symfony/var/cache/{dev,prod} /symfony/var/log
RUN COMPOSER_ALLOW_SUPERUSER=1 composer install --classmap-authoritative --no-dev
RUN COMPOSER_ALLOW_SUPERUSER=1 composer dump-env prod

# removes hardcoded option `ATTR_STATEMENT_CLASS` conflicting with `ATTR_PERSISTENT`. Hack not needed when upgrading to Doctrine 3
# see https://github.com/doctrine/dbal/issues/2315
RUN sed -i '/PDO::ATTR_STATEMENT_CLASS/d' ./vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php

RUN php bin/console cache:clear

CMD service php7.3-fpm start && \
Expand Down