papi/papi

Slim Framework Builder

This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.

Maintainers

Package info

github.com/4uruanna/papi

pkg:composer/papi/papi

Statistics

Installs: 221

Dependents: 6

Suggesters: 0

Stars: 0

Open Issues: 0

v2.1.1 2025-12-22 15:45 UTC

This package is auto-updated.

Last update: 2026-01-22 16:01:52 UTC


README

Description

Help with creating new Slim API. Distributed under the Apache-2.0 license.

Installation

composer require papi/papi

Usage

require __DIR__ . "/../vendor/autoload.php";

use Papi\PapiBuilder;
use function DI\create;

$definitions = [ FooDefinition::class => create()->constructor() ];

$builder = new PapiBuilder();

$app = $builder->setActions(FooGet::class)
    ->setDefinition($definitions)
    ->setEvent(FooEvent::class, BarEvent::class)
    ->setModule(FooModule::class, BarModule::class)
    ->build();

$app->run();

Samples

Events

Order Phase Options
1 START []
2 CONFIGURE_DEFINITIONS [container_builder ➡ ContainerBuilder, definitions ➡ array]
3 CONFIGURE_MIDDLEWARES [app ➡ App, middlewares ➡ array]
4 CONFIGURE_ACTIONS [app ➡ App, actions ➡ array]
5 END [app ➡ App]

Modules Availables

Name Github Packagist
Cache GitHub Packagist
CORS GitHub Packagist
CORS GitHub Packagist
Date GitHub Packagist
DotEnv GitHub Packagist
Http Error GitHub Packagist

Test

composer test

Call API From Test

use Papi\Test\PapiTestCase;
use Papi\Test\mock\FooGet;
use PHPUnit\Framework\Attributes\CoversClass;

class CustomTest extends PapiTestCase
{
    public function testLoadActions(): void
    {
        $body = [ "attribute" => 1 ];
        $request = $this->createRequest('GET', '/foo', $body);
        $builder = new PapiBuilder();

        $response = $builder
            ->setAction([FooGet::class])
            ->handle($request);

        $this->assertEquals(200, $response->getStatusCode());
        $this->assertEquals("foo", (string) $response->getBody());
    }
}

Resources