From 26b2a3c74739f108be3f00e714cdcb609720be5e Mon Sep 17 00:00:00 2001 From: Oh My Felix Date: Thu, 4 Jun 2026 21:54:05 +0000 Subject: [PATCH] Docs: move documentation to README --- .docs/README.md | 120 --------------------------------------------- README.md | 126 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 116 insertions(+), 130 deletions(-) delete mode 100644 .docs/README.md diff --git a/.docs/README.md b/.docs/README.md deleted file mode 100644 index 1436f12..0000000 --- a/.docs/README.md +++ /dev/null @@ -1,120 +0,0 @@ -# Contributte API - -Powerful, documented, validated, built-in API to Nette Framework. - -## Content - -- [Setup](Setup) - -## Setup - -```bash -composer require contributte/api -``` - -## Configuration - -### Minimal configuration - -NEON configration: - -```neon -extensions: - api: Contributte\Api\DI\ApiExtension - -services: - - App\Api\PingController - - App\Api\PingController -``` - -Router configuration: - -```php -namespace App\Domain\Routing; - -use App\Api\HelloController; -use Contributte\Api\Router\ApiRouter; -use Nette\Application\Routers\Route; -use Nette\Application\Routers\RouteList; -use Nette\Routing\Router; - -class RouterFactory -{ - - public static function create(): Router - { - $router = new RouteList(); - - $api = (new ApiRouter($router))->withPath('api'); - $api->add('GET', 'hello', HelloController::class); - - $router[] = new Route('/[/]', 'Home:default'); - - return $router; - } - -} -``` - -Controller example: - -```php -withPayload('Hello!'); - } - -} -``` - -### Advanced configuration - -```neon -extensions: - api: Contributte\Api\DI\ApiExtension - -api: - middlewares: - # Catch & handler errors - - Contributte\Api\Middleware\TracyMiddleware(%debugMode%) - # Format responses - - Contributte\Api\Middleware\NegotiationMiddleware( - Contributte\Api\Formatter\MultiFormatter([ - Contributte\Api\Formatter\JsonFormatter() - ]) - ) - # Process authentication & authorization - - Contributte\Api\Middleware\MatchMiddleware( - # skip public routes - skipTags: [public] - # apply firewall middleware - middlewares: [ - Contributte\Api\Middleware\FirewallMiddleware( - Contributte\Api\Security\StaticFirewall([ - foobar: [user: Foo, role: Bar] - ]) - ) - ] - ) - # Process controllers - - Contributte\Api\Middleware\DispatcherMiddleware - -search: - # Search for controllers defined in app/Api folder - controllers: - in: %appDir%/Api - files: [*Controller.php] -``` - -### Getting started - -## Examples - -There is example project [contributte/api-skeleton](https://github.com/contributte/api-skeleton). diff --git a/README.md b/README.md index ebca7d5..3aef88a 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,22 @@ -

+

Website 🚀 contributte.org | Contact 👨🏻‍💻 f3l1x.io | Twitter 🐦 @contributte

-## Usage +Powerful, documented, validated, built-in API for Nette Framework. + +## Versions + +| State | Version | Branch | Nette | PHP | +|--------|---------|----------|-------|---------| +| dev | `^0.5` | `master` | 3.2+ | `>=8.2` | +| stable | `^0.4` | `master` | 3.1+ | `>=8.1` | + +## Installation To install the latest version of `contributte/api` use [Composer](https://getcomposer.org). @@ -26,22 +35,119 @@ To install the latest version of `contributte/api` use [Composer](https://getcom composer require contributte/api ``` -## Documentation +## Configuration -For details on how to use this package, check out our [documentation](.docs). +### Minimal configuration -## Version +NEON configuration: -| State | Version | Branch | Nette | PHP | -|--------|---------|----------|-------|---------| -| dev | `^0.5` | `master` | 3.2+ | `>=8.2` | -| stable | `^0.4` | `master` | 3.1+ | `>=8.1` | +```neon +extensions: + api: Contributte\Api\DI\ApiExtension + +services: + - App\Api\HelloController +``` + +Router configuration: + +```php +namespace App\Domain\Routing; + +use App\Api\HelloController; +use Contributte\Api\Router\ApiRouter; +use Nette\Application\Routers\Route; +use Nette\Application\Routers\RouteList; +use Nette\Routing\Router; + +class RouterFactory +{ + + public static function create(): Router + { + $router = new RouteList(); + + $api = (new ApiRouter($router))->withPath('api'); + $api->add('GET', 'hello', HelloController::class); + + $router[] = new Route('/[/]', 'Home:default'); + + return $router; + } + +} +``` + +Controller example: + +```php +withPayload('Hello!'); + } + +} +``` + +### Advanced configuration + +```neon +extensions: + api: Contributte\Api\DI\ApiExtension + +api: + middlewares: + # Catch & handle errors + - Contributte\Api\Middleware\TracyMiddleware(%debugMode%) + # Format responses + - Contributte\Api\Middleware\NegotiationMiddleware( + Contributte\Api\Formatter\MultiFormatter([ + Contributte\Api\Formatter\JsonFormatter() + ]) + ) + # Process authentication & authorization + - Contributte\Api\Middleware\MatchMiddleware( + # skip public routes + skipTags: [public] + # apply firewall middleware + middlewares: [ + Contributte\Api\Middleware\FirewallMiddleware( + Contributte\Api\Security\StaticFirewall([ + foobar: [user: Foo, role: Bar] + ]) + ) + ] + ) + # Process controllers + - Contributte\Api\Middleware\DispatcherMiddleware + +search: + # Search for controllers defined in app/Api folder + controllers: + in: %appDir%/Api + files: [*Controller.php] +``` + +## Examples + +There is example project [contributte/api-skeleton](https://github.com/contributte/api-skeleton). ## Development See [how to contribute](https://contributte.org/contributing.html) to this package. -This package is currently maintaining by these authors. +This package is currently maintained by these authors.