Skip to content

Commit

Permalink
Support Symfony 7, drop support for Symfony 5 (#46)
Browse files Browse the repository at this point in the history
* Updated components - still failing psalm

* Update docker setup

* Update CI setup

* Switched to PHP 8.3 as default

* Updated ids and symfony packages

* Updated Psalm and PHP cs fixer

* Fix psalm issues

* Fix more psalm issues

* Fix last psalm issues

* Improve comments

* Prepared docs for newest release

---------

Co-authored-by: Christian Kolb <[email protected]>
  • Loading branch information
christian-kolb and Christian Kolb authored Mar 11, 2024
1 parent fcaea3c commit fc090ef
Show file tree
Hide file tree
Showing 35 changed files with 1,126 additions and 1,064 deletions.
15 changes: 11 additions & 4 deletions .docker/php-8.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM php:8.2-fpm-alpine3.16
# Build with
# docker buildx build --platform linux/arm64,linux/amd64 -t ghcr.io/digital-craftsman-de/cqrs-php-8.2:latest ./.docker/php-8.2 --push

FROM php:8.2-fpm-alpine

RUN apk add --update \
autoconf \
Expand All @@ -7,12 +10,15 @@ RUN apk add --update \
linux-headers \
curl

# Add php extensions
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync

RUN pecl install xdebug-3.2.2 && docker-php-ext-enable xdebug
# Debugging
RUN install-php-extensions xdebug

RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions uuid
# Ids package
RUN install-php-extensions uuid

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
ln -s $(composer config --global home) /root/composer
Expand All @@ -22,6 +28,7 @@ ADD php.ini /etc/php/conf.d/
ADD php.ini /etc/php/cli/conf.d/
ADD php.ini /usr/local/etc/php
ADD php-fpm.conf /etc/php/php-fpm.d/
ADD docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/

WORKDIR /var/www/html

Expand Down
7 changes: 7 additions & 0 deletions .docker/php-8.2/docker-php-ext-xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
zend_extension=xdebug
xdebug.mode=off
xdebug.start_with_request=trigger
xdebug.discover_client_host=0
xdebug.client_host=host.docker.internal
xdebug.output_dir=/var/www/html/var/profiler
xdebug.profiler_output_name=cachegrind.out.%R.%t
15 changes: 11 additions & 4 deletions .docker/php-8.3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM php:8.3-fpm-alpine3.18
# Build with
# docker buildx build --platform linux/arm64,linux/amd64 -t ghcr.io/digital-craftsman-de/cqrs-php-8.3:latest ./.docker/php-8.3 --push

FROM php:8.3-fpm-alpine

RUN apk add --update \
autoconf \
Expand All @@ -7,12 +10,15 @@ RUN apk add --update \
linux-headers \
curl

# Add php extensions
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync

RUN pecl install xdebug-3.3.0 && docker-php-ext-enable xdebug
# Debugging
RUN install-php-extensions xdebug

RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions uuid
# Ids package
RUN install-php-extensions uuid

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
ln -s $(composer config --global home) /root/composer
Expand All @@ -22,6 +28,7 @@ ADD php.ini /etc/php/conf.d/
ADD php.ini /etc/php/cli/conf.d/
ADD php.ini /usr/local/etc/php
ADD php-fpm.conf /etc/php/php-fpm.d/
ADD docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/

WORKDIR /var/www/html

Expand Down
7 changes: 7 additions & 0 deletions .docker/php-8.3/docker-php-ext-xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
zend_extension=xdebug
xdebug.mode=off
xdebug.start_with_request=trigger
xdebug.discover_client_host=0
xdebug.client_host=host.docker.internal
xdebug.output_dir=/var/www/html/var/profiler
xdebug.profiler_output_name=cachegrind.out.%R.%t
90 changes: 81 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,39 @@ jobs:
name: "Tests on PHP 8.2"
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup env
run: cp .github/workflows/.env .env

- name: Cache PHP 8.2 dependencies
id: cache-php-8-2-dependencies
uses: actions/cache@v3
env:
cache-name: cache-php-8-2-dependencies
with:
path: |
~/.cache
vendor
key: ${{ runner.os }}-php-8-2-cache-${{ hashFiles('composer.lock') }}
restore-keys: |
${{ runner.os }}-php-8-2-cache-${{ hashFiles('composer.lock') }}
- name: Install
run: |
cp .github/workflows/.env .env
make install-8.2
if: steps.cache-php-8-2-dependencies.outputs.cache-hit != 'true'
run: make install-8.2

- name: Run PHP tests
run: make php-8.2-tests-ci

- name: Upload to Codecov
uses: codecov/codecov-action@v2
with:
Expand All @@ -24,22 +50,68 @@ jobs:
name: "Tests on PHP 8.3"
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup env
run: cp .github/workflows/.env .env

- name: Cache PHP 8.3 dependencies
id: cache-php-8-3-dependencies
uses: actions/cache@v3
env:
cache-name: cache-php-8-3-dependencies
with:
path: |
~/.cache
vendor
key: ${{ runner.os }}-php-8-3-cache-${{ hashFiles('composer.lock') }}
restore-keys: |
${{ runner.os }}-php-8-3-cache-${{ hashFiles('composer.lock') }}
- name: Install
run: |
cp .github/workflows/.env .env
make install-8.3
if: steps.cache-php-8-3-dependencies.outputs.cache-hit != 'true'
run: make install-8.3

- name: Run PHP tests
run: make php-8.3-tests-ci

code-validation:
name: "Code validation"
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup env
run: cp .github/workflows/.env .env

- name: Restore cache for PHP 8.3 dependencies
id: cache-php-8-3-dependencies
uses: actions/cache/restore@v3
with:
path: |
~/.cache
vendor
key: ${{ runner.os }}-php-8-3-cache-${{ hashFiles('composer.lock') }}

- name: Install
run: |
cp .github/workflows/.env .env
make install
if: steps.cache-php-8-3-dependencies.outputs.cache-hit != 'true'
run: make install-8.3

- name: Run code validation
run: make php-code-validation
8 changes: 8 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,13 @@
'less_and_greater' => false,
'always_move_variable' => true,
],

// Add spaces around union and intersection types
'types_spaces' => [
'space' => 'single',
],

// Nullable types should be explicit even with default values
'nullable_type_declaration_for_default_null_value' => false,
])
->setFinder($finder);
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.13.0

- **[Breaking change](./UPGRADE.md#upgrade-to-at-least-symfony-64)**: Dropped support for Symfony 5.
- Added support for Symfony 7.

## 0.12.0

- **[Breaking change](./UPGRADE.md#switched-handler-methods)**: Switched from `handle` to `__invoke` method for `CommandHandlerInterface` and `QueryHandlerInterface`. This way the specific command or query can be type hinted in the method signature.
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ reset: .reset

## install Install PHP dependencies with the default PHP version (8.2).
.PHONY: .install
install: install-8.2
install: install-8.3

## install-8.2 Install PHP dependencies with PHP 8.2.
.PHONY: install-8.2
Expand All @@ -68,7 +68,7 @@ install-8.3:

## php-cli Enter a shell for the default PHP version (8.2).
.PHONY: php-cli
php-cli: php-8.2-cli
php-cli: php-8.3-cli

## php-8.2-cli Enter a shell for PHP 8.2.
.PHONY: php-8.2-cli
Expand Down Expand Up @@ -116,8 +116,8 @@ php-8.3-tests-html-coverage:
## php-code-validation Run code fixers and linters with default PHP version (8.2).
.PHONY: php-code-validation
php-code-validation:
docker-compose run --rm php-8.2 ./vendor/bin/php-cs-fixer fix
docker-compose run --rm php-8.2 ./vendor/bin/psalm --show-info=false --no-diff
docker-compose run --rm php-8.3 ./vendor/bin/php-cs-fixer fix
docker-compose run --rm php-8.3 ./vendor/bin/psalm --show-info=false --no-diff

##
## CI
Expand Down
6 changes: 6 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Upgrade guide

## From 0.12.* to 0.13.0

### Upgrade to at least Symfony 6.4

Support for Symfony 5 was dropped, so you have to upgrade to at least Symfony 6.4. You might also directly upgrade to Symfony 7.

## From 0.11.* to 0.12.0

### Switched handler methods
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
"type": "symfony-bundle",
"require": {
"php": "8.2.*|8.3.*",
"symfony/framework-bundle": "^5.4|^6.0",
"symfony/serializer": "^5.4|^6.0"
"symfony/framework-bundle": "^6.4|^7.0",
"symfony/serializer": "^6.4|^7.0"
},
"require-dev": {
"digital-craftsman/ids": "0.9.*",
"digital-craftsman/ids": "0.13.*",
"friendsofphp/php-cs-fixer": "^3.15",
"phpunit/phpunit": "^9.5",
"symfony/property-access": "^6.2",
"symfony/property-info": "^6.2",
"symfony/yaml": "^6.2",
"vimeo/psalm": "^4.12"
"symfony/property-access": "^7.0",
"symfony/property-info": "^7.0",
"symfony/yaml": "^7.0",
"vimeo/psalm": "^5.17"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit fc090ef

Please sign in to comment.