Skip to content

Commit

Permalink
Implement basic integration.
Browse files Browse the repository at this point in the history
  • Loading branch information
Invis1ble committed Jun 3, 2024
0 parents commit deed6af
Show file tree
Hide file tree
Showing 26 changed files with 676 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# 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=74f6de3f7a6ba3a9ddc199911cadfc6b
###< symfony/framework-bundle ###
4 changes: 4 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# define your env variables for the test env here
KERNEL_CLASS='Invis1ble\SerializerExtensionBundle\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: CI

on: [push, pull_request]

jobs:
tests:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build Docker images
uses: docker/bake-action@v4
with:
pull: true
load: true
files: |
compose.yaml
compose.override.yaml
set: |
*.cache-from=type=gha,scope=${{github.ref}}
*.cache-from=type=gha,scope=refs/heads/main
*.cache-to=type=gha,scope=${{github.ref}},mode=max
-
name: Start services
run: docker compose up --wait --no-build
env:
XDEBUG_MODE: coverage
-
name: Install Dependencies
run: docker compose exec -T php composer install -vvv --no-ansi --no-interaction
-
name: Check Code Quality via PHP_CodeSniffer
run: docker compose exec -T php bin/php_codesniffer
-
name: Check Code Quality via PHP-CS-Fixer
run: docker compose exec -T php bin/php-cs-fixer
-
name: Rector Cache
uses: actions/cache@v4
with:
path: /tmp/rector
key: ${{ runner.os }}-rector-${{ github.run_id }}
restore-keys: ${{ runner.os }}-rector-
-
run: mkdir -p /tmp/rector
-
name: Rector Dry Run
run: docker compose exec -T php bin/rector
-
name: Execute tests via PHPUnit
run: docker compose exec -T php vendor/bin/phpunit --coverage-clover var/log/coverage-clover.xml
-
name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
lint:
name: Docker Lint
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Lint Dockerfile
uses: hadolint/[email protected]
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/var/
/vendor/
composer.lock

###> friendsofphp/php-cs-fixer ###
/.php-cs-fixer.cache
/.php-cs-fixer.php
###< friendsofphp/php-cs-fixer ###

###> phpunit/phpunit ###
/.phpunit.result.cache
###< phpunit/phpunit ###

###> squizlabs/php_codesniffer ###
/.phpcs.cache
###< squizlabs/php_codesniffer ###

###> phpstan/phpstan ###
phpstan.neon
###< phpstan/phpstan ###
36 changes: 36 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
->exclude('vendor')
->in(__DIR__)
;

return (new Config())
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'multiline_comment_opening_closing' => true, // @PhpCsFixer default
'comment_to_phpdoc' => [
'ignored_tags' => [],
], // @PhpCsFixer:risky default
'concat_space' => [
'spacing' => 'one',
], // overrides @Symfony defaults
'single_line_throw' => false, // overrides @Symfony defaults
'trailing_comma_in_multiline' => [
'after_heredoc' => true,
'elements' => [
'arguments',
'arrays',
'match',
'parameters',
],
], // overrides @Symfony defaults
])
->setFinder($finder)
;
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM php:8.2-cli

ENV XDEBUG_MODE=off

RUN apt-get update && apt-get install -y --no-install-recommends \
git=1:2.39.2-1.1 \
unzip=6.0-28 \
&& rm -rf /var/lib/apt/lists/*

RUN bash -c '[[ -n "$(pecl list | grep xdebug)" ]]\
|| (pecl install xdebug-3.3.2 && docker-php-ext-enable xdebug)'

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

WORKDIR /app

COPY . .
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2023 Invis1ble.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
105 changes: 105 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
SerializerExtensionBundle
=========================

![CI Status](https://github.com/Invis1ble/serializer-extension-bundle/actions/workflows/ci.yml/badge.svg?event=push)
[![Code Coverage](https://codecov.io/gh/Invis1ble/serializer-extension-bundle/graph/badge.svg?token=K7S3BXER5K)](https://codecov.io/gh/Invis1ble/serializer-extension-bundle)
[![Packagist](https://img.shields.io/packagist/v/Invis1ble/serializer-extension-bundle.svg)](https://packagist.org/packages/Invis1ble/serializer-extension-bundle)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)

The `SerializerExtensionBundle` provides integration of the [invis1ble/serializer-extension](https://github.com/Invis1ble/serializer-extension) library into the Symfony framework.


Installation
------------

Make sure Composer is installed globally, as explained in the
[installation chapter](https://getcomposer.org/doc/00-intro.md)
of the Composer documentation.

### Applications that use Symfony Flex

Open a command console, enter your project directory and execute:

```console
$ composer require invis1ble/serializer-extension-bundle
```

### Applications that don't use Symfony Flex

#### Step 1: Download the Bundle

Open a command console, enter your project directory and execute the
following command to download the latest stable version of this bundle:

```console
$ composer require invis1ble/serializer-extension-bundle
```

#### Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles
in the `config/bundles.php` file of your project:

```php
// config/bundles.php

return [
// ...
Invis1ble\SerializerExtensionBundle\Invis1bleSerializerExtensionBundle::class => ['all' => true],
];
```


Development
-----------

### Getting started

1. If not already done, [install Docker Compose](https://docs.docker.com/compose/install/) (v2.10+)
2. Run `docker compose build --no-cache` to build fresh images
3. Run `docker compose up -d --wait` to start the Docker containers
4. Run `docker compose exec php composer install` to install dependencies
5. Run `docker compose down --remove-orphans` to stop the Docker containers.

### Check for Coding Standards violations

Run PHP_CodeSniffer checks:

```sh
docker compose exec -it php bin/php_codesniffer
```

Run PHP-CS-Fixer checks:

```sh
docker compose exec -it php bin/php-cs-fixer
```

Run Rector checks:

```sh
docker compose exec -it php bin/rector
```


Testing
-------

To run Unit tests during development

```sh
docker compose exec php vendor/bin/phpunit
```

To run with coverage

```sh
XDEBUG_MODE=coverage docker compose up -d --wait
docker compose exec php vendor/bin/phpunit --coverage-clover var/log/coverage-clover.xml
```


License
-------

[The MIT License](./LICENSE)
8 changes: 8 additions & 0 deletions bin/php-cs-fixer
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

vendor/bin/php-cs-fixer fix \
--config=.php-cs-fixer.dist.php \
-v \
--dry-run \
--using-cache=no \
--diff
5 changes: 5 additions & 0 deletions bin/php_codesniffer
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

vendor/bin/phpcs \
-p \
--report=code,gitblame
5 changes: 5 additions & 0 deletions bin/rector
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

vendor/bin/rector process \
--config=rector.php \
--dry-run
9 changes: 9 additions & 0 deletions compose.override.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
php:
build: .
volumes:
- .:/app
environment:
# See https://xdebug.org/docs/all_settings#mode
XDEBUG_MODE: "${XDEBUG_MODE:-off}"
tty: true
3 changes: 3 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
services:
php:
image: php:8.2-cli
49 changes: 49 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "invis1ble/serializer-extension-bundle",
"type": "symfony-bundle",
"description": "Symfony Bundle for symfony/serializer extension.",
"authors": [
{
"name": "Invis1ble",
"email": "[email protected]"
}
],
"keywords": [
"serializer",
"deserializer",
"normalizer",
"denormalizer",
"uri",
"url",
"uriinterface",
"psr",
"extension",
"symfony-bundle"
],
"require": {
"php": ">=8.1",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/config": "^6.4|^7.0",
"invis1ble/symfony-serializer-extension": "dev-main",
"guzzlehttp/guzzle": "8.0.x-dev"
},
"require-dev": {
"escapestudios/symfony2-coding-standard": "^3.0@dev",
"friendsofphp/php-cs-fixer": "dev-master",
"matthiasnoback/symfony-dependency-injection-test": "^5.0",
"rector/rector": "dev-main",
"symfony/framework-bundle": "<=7.0.7",
"symfony/test-pack": "^1.0",
"symfony/dotenv": "7.2.x-dev"
},
"autoload": {
"psr-4": {
"Invis1ble\\SerializerExtensionBundle\\": "src/",
"Invis1ble\\SerializerExtensionBundle\\Tests\\": "tests/"
},
"exclude-from-classmap": ["/tests/"]
},
"minimum-stability": "dev",
"license": "MIT"
}
6 changes: 6 additions & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['test' => true],
Invis1ble\SerializerExtensionBundle\Invis1bleSerializerExtensionBundle::class => ['test' => true],
];
Loading

0 comments on commit deed6af

Please sign in to comment.