Statistics
18700
20
8
49d
Badges
Tags
api
Dependencies

Apitte\Core

🔧 Core API library for Nette Framework.


Build Status Code coverage Licence

Downloads this Month Downloads total Latest stable

Discussion / Help

Join the chat

Install

composer require apitte/core

Version

State Version Branch PHP Composer
development ^0.5.0 master >= 7.1 minimum-stability: dev, prefer-stable: true
stable ^0.4.0 master >= 7.1
stable ^0.3.0 master >= 5.6

Example

Just define some endpoints, I mean controllers. Place some annotations and thats all.

namespace App\Controllers;

use Apitte\Core\Annotation\Controller\Controller;
use Apitte\Core\Annotation\Controller\ControllerPath;
use Apitte\Core\Annotation\Controller\Method;
use Apitte\Core\Annotation\Controller\Path;
use Apitte\Core\Http\ApiRequest;
use Apitte\Core\Http\ApiResponse;
use Apitte\Core\UI\Controller\IController;

/**
 * @Controller
 * @ControllerPath("/hello")
 */
final class HelloController implements IController
{

    /**
     * @Path("/world")
     * @Method("GET")
     */
    public function index(ApiRequest $request, ApiResponse $response): ApiResponse
    {
        return $response->writeBody('Hello world!');
    }
}

And register your controller as service.

services:
    - App\Controllers\HelloController

As you can see, the architecture is ultra simple. ApiRequest & ApiResponse wrap PSR-7, so you can re-use these declared methods.

Overview

Maintainers


Milan Felix Šulc

Marek Bartoš

The development is sponsored by Tlapnet and a lot of coffees. Thank you guys! 👍


Thank you for testing, reporting and contributing.

  • v0.4 v0.4

    Bump! 🎉

    Diff: v0.3...v0.4

    Changes:

    • Strict types and native typehints (#18)
    • phpstan 0.10
    • rewrited exceptions - more consistent and meaningful
    • normalized behavior for tags - all tags could have an optional value (#27)
    • router throws 405 instead of 404 for methods which are unsupported by endpoint (#54)
    • removed BadRequestException and RequestException (api should use ClientErrorException and ServerErrorException only) (#60)
    • fully implemented request parameters (#44, #40, #52)
      • check format of variable instead of magical typecasting
      • implemented datetime and boolean
      • removed scalar (use string instead) and object (not implemented)
      • removed support for custom types (in consistence with openapi - only object type may be returned in future)
    • validations
      • each request parameter in path must be defined in mask and each mask parameter must be defined in request parameters
      • check validity of request parameter attributes and validity of combination of these attributes
      • allow only one default suffix for response mappers and require all suffixes to be unique
      • check validity of negotiations (#28)
    • optimizations
      • check renderers, request and response entities validity in compile-time
    • fixes
      • fix case where non-last decorator returned null
      • Method::addArguments - arguments order (affects only very low-level usage)
  • v0.3 v0.3

    Bump! 🎃

    Diff: v0.2...v0.3

    Changes:

    • Mapping: normalize request parameter with respect to parameter IN [#14] (thanks @trejjam)
    • Openapi: extend configuration [#17] (thanks @trejjam)
    • Fix bug with required non-empty parameter [#15] (thanks @trejjam)

    This is last PHP 5.6 release.

  • v0.2 v0.2

    Bump! 🇫🇰

    Diff: v0.1.1...v0.2

    Changes:

    • added RequestMapper/ResponseMapper + validation
    • better ArraySerializator
    • added frequently used method to Endpoint
    • simplify events in Dispatcher
    • pass query parameters into attributes
    • validate only fullpath (GroupPath+ControllerPath+Path)
    • better exception [#13]
  • v0.1.1

    Bump! ⛵️

    Diff: v0.1...v0.1.1

    Changes:

    • typo [#5]
    • allow prefixed annotations [#6, #7]
    • better RequestParameters [#8]
  • v0.1 v0.1

    First bump! 👊

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette admin@componette.com