reinvanoyen / dry-internal-api
An internal API for your DRY applications
Installs: 63
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/reinvanoyen/dry-internal-api
Requires
- reinvanoyen/oak: ^1.0.0
- reinvanoyen/oak-console-table: ^1.0.0
This package is auto-updated.
Last update: 2025-09-10 21:22:19 UTC
README
An internal API for your DRY applications
Installation
composer require reinvanoyen/dry-internal-api
Example usage
Route definition
<?php use Tnt\InternalApi\Facade\Api; Api::get('posts/', '\\Acme\\Controller\\PostController::index'); Api::post('posts/', '\\Acme\\Controller\\PostController::add'); Api::delete('posts/(?<postId>\d+)/', '\\Acme\\Controller\\PostController::delete');
Controller
<?php namespace Acme\Controller; use Tnt\InternalApi\Exception\ApiException; use Tnt\InternalApi\Http\Request; class PostController { public static function index(Request $request) { return [ [ 'id' => 1, 'title' => 'My example post', ], [ 'id' => 2, 'title' => 'Another example post', ], ]; } public static function add(Request $request) { // Create your post } public static function delete(Request $request) { if ($request->data->integer('postId')) { // Delete your post return true; } throw new ApiException('post_not_found'); } }