PHPackages                             kairos-project/api-loader - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. kairos-project/api-loader

ActiveLibrary[API Development](/categories/api)

kairos-project/api-loader
=========================

A data loader listener to be attached to ApiController events

017PHP

Since Aug 25Pushed 7y ago1 watchersCompare

[ Source](https://github.com/kairosProject/ApiLoader)[ Packagist](https://packagist.org/packages/kairos-project/api-loader)[ RSS](/packages/kairos-project-api-loader/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

ApiLoader
=========

[](#apiloader)

A data loader listener to be attached to ApiController events.

1) Subject
----------

[](#1--subject)

The data charging is an essential part of each app and web projects. As such, the API part of Kairos project have to be able to load, store, validate the client data, and so more.

The ApiLoader system as itself is in charge of the data loading part of this feature. It has to work with a large quantity of driver, adapter or web-services clients. By the way, the genericity of this segment is the key feature. By default, it won't implement any loading logic but only a general paradigm.

At a first level, the component will have to process two well-known operations:

- load a specific item
- load a set of items

To rely upon the ApiController library, the ApiLoader will define it as a dependency. Then it became possible to integrate the event dispatching logic. This logic will allow the developers to attach some query building extension. These extensions will work with a query building event instead of the top ApiController level ProcessEvent.

As the original event contains references to request, possibly needed by extensions, the new one will offer access to it.

2) Class architecture
---------------------

[](#2-class-architecture)

The API loader system is a placeholder for more specific data access objects (DAO). To follow this principle the element cannot implement a data loading algorithm but will contribute to offer an abstract loading workflow to be inherited by specific DAO.

The abstract loader will implement three methods, as a unique entry point for the two basics loading operations. These two are :

- loadCollection
- loadItem

The element will have to manage a logging system, to ensure the traceability of the system.

3) Dependency description and use into the element
--------------------------------------------------

[](#3-dependency-description-and-use-into-the-element)

A the time of writing, the API controller is designed to have three production dependencies as:

- psr/log
- symfony/event-dispatcher
- kairos-project/api-controller

### 3.1) psr/log

[](#31-psrlog)

The debugging and error retracement in each project parts is currently a fundamental law in development and it's missing is part of the OWASP top ten threats.

As defined by the third PHP standard reference, the logger components have to implement a specific interface. By the way, the logging system will be usable by each existing frameworks.

### 3.2) symfony/event-dispatcher

[](#32-symfonyevent-dispatcher)

The API loader system is designed to be easily extendable and will implement an event dispatching system, allowing the attachment and separation of logic by priority.

### 3.3) kairos-project/api-controller

[](#33-kairos-projectapi-controller)

The API loader is made to be used by APIs and the generic system into kairos project is the API controller. This system offer access to specialized workflow events.

The loader will define the controller component as a dependency to make use of the workflow events.

4) Implementation specification
-------------------------------

[](#4-implementation-specification)

As explained in section two, the abstract class will implement the 'loadCollection' and 'loadItem' methods.

#### 4.1) Dependency injection specification

[](#41-dependency-injection-specification)

The instance will receive the logger instance and the event dispatcher at the instantiation directly in the constructor.

For a configuration capability, two event names can be provided to define the query building dispatch's events. These elements will have a default value, define by constant.

A query result key can also be defined.

#### 4.2) loadCollection method algorithm

[](#42-loadcollection-method-algorithm)

The loadCollection method is designed to find and load a collection of item.

```
We assume to receive the process event from the parameters.
We assume to receive the event name from the parameters.
We assume to receive the event dispatcher from the parameters.

Get a queryBuilding event from the getQueryBuildingEvent by offer the initial event.
Provide the event to instanciateQueryBuilder, and inject a new queryBuilder.
Provide the event to configureQueryForCollection. This step configures the queryBuilder.
Dispatch a query building event name. This action allows the modification of the query by some attached extensions.
Execute the query for collection and insert the result into the original event, at a defined key.
```

#### 4.3) loadItem method algorithm

[](#43-loaditem-method-algorithm)

The loadItem method is designed to find and load a specific item.

```
We assume to receive the process event from the parameters.
We assume to receive the event name from the parameters.
We assume to receive the event dispatcher from the parameters.

Get a queryBuilding event from the getQueryBuildingEvent by offer the initial event.
Provide the event to instanciateQueryBuilder, and inject a new queryBuilder.
Provide the event to configureQueryForItem. This step configures the queryBuilder.
Dispatch a query building event name. This action allows the modification of the query by some attached extensions.
Execute the query for an item and insert the result into the original event, at a defined key.
If the item is empty and the loader is configured to throw an exception in such case, it will throw a runtime exception with code 404.
```

#### 4.4) Event specification

[](#44-event-specification)

The query building event, defined by the library is the transport element of the initial process event and the query builder. It will have to inherit the base event logic and store the process event at instantiation and provide a setQuery method.

The event will have to offer getters, to retrieve the stored elements. A getQuery and a getProcessEvent will be part of the component operations.

5) Usage
--------

[](#5-usage)

The API loader only offers an abstract class and cannot be used itself.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12436206?v=4)[cscfa](/maintainers/cscfa)[@cscfa](https://github.com/cscfa)

---

Top Contributors

[![matthieu88160](https://avatars.githubusercontent.com/u/11874266?v=4)](https://github.com/matthieu88160 "matthieu88160 (9 commits)")

### Embed Badge

![Health badge](/badges/kairos-project-api-loader/health.svg)

```
[![Health](https://phpackages.com/badges/kairos-project-api-loader/health.svg)](https://phpackages.com/packages/kairos-project-api-loader)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
