Oihana PHP System

ApiTrait

Trait providing helpers to manage the application instance and generate URLs.

This trait allows controllers to access the Slim App instance, retrieve the application's base path, and build URLs with optional query parameters.

Note: You can define a baseUrl in the DI container to use it consistently across all controllers.

Table of Contents

Properties

$api  : array<string|int, mixed>
The default api settings.

Methods

initializeApi()  : static
Initializes the internal `api` settings.

Properties

$api

The default api settings.

protected array<string|int, mixed> $api = []

Methods

initializeApi()

Initializes the internal `api` settings.

public initializeApi([array<string|int, mixed> $init = [] ][, ContainerInterface|null $container = null ]) : static

By default, this method search in the DI container a ControllerParam::API definition to initialize the "api" property.

Parameters
$init : array<string|int, mixed> = []

Optional initialization array (e.g., ['api' => [ ... ] ] ).

$container : ContainerInterface|null = null

Optional DI container for retrieving the 'api' array representation.

Tags
throws
NotFoundExceptionInterface

If the container is used and the 'api' definition is not found in the DI container.

throws
ContainerExceptionInterface

If the container throws an internal error.

throws
RuntimeException

If no valid App instance is provided or found.

Return values
static

Returns the current controller instance for method chaining.


        
On this page

Search results