Skip to content

Commit 27683f8

Browse files
authored
[symfony-raw] Fix and update to PHP 8.1 (#7102)
* [symfony-raw] Fix and update to PHP 8.1 * Small change to run tests in github
1 parent 5b5877f commit 27683f8

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

frameworks/PHP/symfony/src/Controller/DbRawController.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ public function __construct(Connection $connection)
2424
public function db(): JsonResponse
2525
{
2626
$statement = $this->connection->prepare('SELECT id,randomNumber FROM World WHERE id = ?');
27-
$statement->execute([mt_rand(1, 10000)]);
28-
$world = $statement->fetch(FetchMode::ASSOCIATIVE);
27+
$world = $statement->execute([mt_rand(1, 10000)]);
2928

30-
return new JsonResponse($world);
29+
return new JsonResponse($world->fetchAssociative());
3130
}
3231

3332
/**
@@ -43,8 +42,8 @@ public function queries(Request $request): JsonResponse
4342

4443
$statement = $this->connection->prepare('SELECT id,randomNumber FROM World WHERE id = ?');
4544
for ($i = 0; $i < $queries; ++$i) {
46-
$statement->execute([mt_rand(1, 10000)]);
47-
$worlds[] = $statement->fetch(FetchMode::ASSOCIATIVE);
45+
$world = $statement->execute([mt_rand(1, 10000)]);
46+
$worlds[] = $world->fetchAssociative();
4847
}
4948

5049
return new JsonResponse($worlds);
@@ -65,8 +64,8 @@ public function updates(Request $request): JsonResponse
6564

6665
for ($i = 0; $i < $queries; ++$i) {
6766
$id = mt_rand(1, 10000);
68-
$readStatement->execute([$id]);
69-
$world = $readStatement->fetch(FetchMode::ASSOCIATIVE);
67+
$world = $readStatement->execute([$id]);
68+
$world = $world->fetchAssociative();
7069
$writeStatement->execute(
7170
[$world['randomNumber'] = mt_rand(1, 10000), $id]
7271
);

frameworks/PHP/symfony/symfony-raw.dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /de
66
RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
77
RUN apt-get update -yqq > /dev/null && \
88
apt-get install -yqq nginx git unzip curl \
9-
php8.0-cli php8.0-fpm php8.0-mysql \
10-
php8.0-mbstring php8.0-xml php8.0-curl > /dev/null
9+
php8.1-cli php8.1-fpm php8.1-mysql \
10+
php8.1-mbstring php8.1-xml php8.1-curl > /dev/null
1111

1212
RUN curl -sSL https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
1313

14-
COPY deploy/conf/* /etc/php/8.0/fpm/
15-
RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 1024|pm.max_children = 512|g" /etc/php/8.0/fpm/php-fpm.conf ; fi;
14+
COPY deploy/conf/* /etc/php/8.1/fpm/
15+
RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 1024|pm.max_children = 512|g" /etc/php/8.1/fpm/php-fpm.conf ; fi;
1616

1717
WORKDIR /symfony
1818
ADD ./composer.json /symfony/
@@ -24,12 +24,12 @@ RUN COMPOSER_ALLOW_SUPERUSER=1 composer dump-env prod
2424

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

29-
RUN php bin/console cache:clear
30-
RUN echo "opcache.preload=/symfony/var/cache/prod/App_KernelProdContainer.preload.php" >> /etc/php/8.0/fpm/php.ini
29+
RUN php bin/console cache:clear
30+
RUN echo "opcache.preload=/symfony/var/cache/prod/App_KernelProdContainer.preload.php" >> /etc/php/8.1/fpm/php.ini
3131

3232
EXPOSE 8080
3333

34-
CMD service php8.0-fpm start && \
34+
CMD service php8.1-fpm start && \
3535
nginx -c /symfony/deploy/nginx.conf

0 commit comments

Comments
 (0)