diff --git a/.gitattributes b/.gitattributes index 6313b56..6c44a31 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,11 @@ * text=auto eol=lf + +# Files excluded from the distribution archive installed by Composer. +/tests export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.github export-ignore +/AGENTS.md export-ignore +/mago.toml export-ignore +/phpstan.neon export-ignore +/phpunit.xml.dist export-ignore diff --git a/.gitea/workflows/tests.yml b/.gitea/workflows/tests.yml new file mode 100644 index 0000000..b55466d --- /dev/null +++ b/.gitea/workflows/tests.yml @@ -0,0 +1,34 @@ +name: Tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + check: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.3', '8.4'] + + name: PHP ${{ matrix.php }} + + steps: + - uses: actions/checkout@v4 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: json + coverage: none + tools: composer:v2 + + - name: Install dependencies + run: composer update --prefer-dist --no-interaction --no-progress + + - name: Run gate + run: composer check diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e0c90d2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,18 @@ +# Changelog + +All notable changes to this project are documented here. The format follows +[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project adheres to +[Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- `Controller`, `CrudController`, `Router`, `Request`, `JsonRequest`, `Response`, `Route`, + `ResourceGateway`, `Middleware` and `Pipeline`. +- Routing with path parameters, 404 and 405 responses carrying an `Allow` header. +- Generic CRUD over a `ResourceGateway` port implemented by the application. +- Security middlewares: `BearerAuth`, `RequireRole`, `RateLimit`, `Cors`. +- Transport middlewares: `Logging`, `ContentNegotiation`. +- Nine typed HTTP exceptions with snake_case JSON bodies. +- MIT license and Composer metadata for Packagist. diff --git a/README.md b/README.md index 580e33f..5974af9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # camelia/controllers +[![Latest Stable Version](https://img.shields.io/packagist/v/camelia/controllers.svg)](https://packagist.org/packages/camelia/controllers) +[![Total Downloads](https://img.shields.io/packagist/dt/camelia/controllers.svg)](https://packagist.org/packages/camelia/controllers) +[![License](https://img.shields.io/packagist/l/camelia/controllers.svg)](https://packagist.org/packages/camelia/controllers) +[![Tests](https://git.dr2gsistemas.duckdns.org/dr2gsistemas/camelia-controller/actions/workflows/tests.yml/badge.svg)](https://git.dr2gsistemas.duckdns.org/dr2gsistemas/camelia-controller/actions) + Framework-agnostic REST controller toolkit: routing, request parsing, validation and JSON responses over any data source. Vanilla PHP, no framework. diff --git a/composer.json b/composer.json index 869ce8d..12cde84 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,7 @@ }, "scripts": { "test": "phpunit --configuration phpunit.xml.dist", + "coverage": "phpunit --configuration phpunit.coverage.xml.dist --coverage-text", "fmt": "mago fmt", "fmt:check": "mago fmt --check", "lint": "mago lint", diff --git a/phpunit.coverage.xml.dist b/phpunit.coverage.xml.dist new file mode 100644 index 0000000..5d24d68 --- /dev/null +++ b/phpunit.coverage.xml.dist @@ -0,0 +1,31 @@ + + + + + + tests/Unit + + + + + src + + + + + + + + + +