Skip to content

Commit

Permalink
Merge pull request #4 from designcise/4.x
Browse files Browse the repository at this point in the history
feat: php version bump to 8.2
  • Loading branch information
designcise authored Jul 1, 2023
2 parents 9b75c52 + af3fab3 commit 784ddc2
Show file tree
Hide file tree
Showing 20 changed files with 3,837 additions and 59 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml export-ignore
/phpstan.neon export-ignore
/test export-ignore
/test export-ignore
2 changes: 2 additions & 0 deletions .github/scripts/run-phpunit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
composer test-report
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on: [push]

jobs:
build-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
- name: Install dependencies
uses: php-actions/composer@v6
with:
version: 2.5.5

- name: Test & Coverage
uses: paambaati/codeclimate-action@v4.0.0
env:
CC_TEST_REPORTER_ID: b9873e5d887bdd5e654040a0056c2f6ebfbbf5f9b85eaacd26336bf2f27d6628
with:
coverageCommand: ./.github/scripts/run-phpunit.sh
coverageLocations: coverage.xml:clover
debug: true

- name: Clean up GitHub workspace
uses: docker://ubuntu:latest
with:
args: find /github/workspace/. -name . -o -prune -exec rm -rf -- {} +
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
/.idea
.DS_Store
*.cache
composer.lock
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# License

### Copyright (c) 2017-2022 Daniyal Hamid (https://designcise.com)
### Copyright (c) 2017-2023 Daniyal Hamid (https://designcise.com)

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:

Expand Down
53 changes: 49 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# BitFrame\FastRoute

[![codecov](https://codecov.io/gh/designcise/bitframe-fastroute/branch/master/graph/badge.svg)](https://codecov.io/gh/designcise/bitframe-fastroute)
[![Build Status](https://travis-ci.com/designcise/bitframe-fastroute.svg?branch=master)](https://travis-ci.com/designcise/bitframe-fastroute)
[![CI](https://github.com/designcise/bitframe-fastroute/actions/workflows/ci.yml/badge.svg)](https://github.com/designcise/bitframe-fastroute/actions/workflows/ci.yml)
[![Maintainability](https://api.codeclimate.com/v1/badges/b4f08707fc26da971047/maintainability)](https://codeclimate.com/github/designcise/bitframe-fastroute/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/b4f08707fc26da971047/test_coverage)](https://codeclimate.com/github/designcise/bitframe-fastroute/test_coverage)

FastRoute wrapper class to manage http routes as a middleware.

Expand All @@ -13,9 +14,53 @@ Install using composer:
$ composer require designcise/bitframe-fastroute
```

Please note that this package requires PHP 8.1.0 or newer.
Please note that this package requires PHP 8.2.0 or newer.

## Usage Example
## Examples

### Using Attributes for Route Declaration

```php
class SomeController
{
#[Route(['GET'], '/hello/123')]
public function indexAction(
ServerRequestInterface $request,
RequestHandlerInterface $handler,
): ResponseInterface {
$response = $handler->handle($request);
$response->getBody()->write(
"BitFramePHP - 👋 Build Something Amazing Today!"
);

return $response;
}
}
```

```php
use BitFrame\App;
use BitFrame\Emitter\SapiEmitter;
use BitFrame\FastRoute\Router;
use SomeController;

require 'vendor/autoload.php';

$app = new App();
$router = new Router();

$router->registerControllers([
new SomeController(),
]);

$app->run([
SapiEmitter::class,
$router,
// ...
]);
```

### Using Inline Callback to Handle Route

```php
use BitFrame\App;
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
}
],
"require": {
"php": ">=8.1",
"psr/http-message": "^1.0",
"psr/http-server-middleware": "~1.0",
"designcise/bitframe": "^3.6"
"php": ">=8.2",
"psr/http-message": "^2.0",
"psr/http-server-middleware": "^1.0",
"designcise/bitframe": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
Expand Down Expand Up @@ -41,6 +41,7 @@
"style-fix": "vendor/bin/phpcbf --standard=PSR12 src",
"check": "vendor/bin/phpstan analyse src --level=5 -c phpstan.neon",
"md": "vendor/bin/phpmd src text cleancode,unusedcode,codesize,design,naming",
"test": "vendor/bin/phpunit --configuration phpunit.xml --testsuite bitframe_fastroute"
"test": "vendor/bin/phpunit --configuration phpunit.xml --testsuite bitframe_fastroute",
"test-report": "vendor/bin/phpunit --configuration phpunit.xml --testsuite bitframe_fastroute --coverage-clover=coverage.xml"
}
}
Loading

0 comments on commit 784ddc2

Please sign in to comment.