PHPackages                             justblink/generic-api - 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. justblink/generic-api

ActiveLibrary[API Development](/categories/api)

justblink/generic-api
=====================

Creates an api, just add orm objects

v0.0.6(6mo ago)02431MITPHP

Since Apr 21Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/CrisHigham/generic-api)[ Packagist](https://packagist.org/packages/justblink/generic-api)[ RSS](/packages/justblink-generic-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (8)Used By (0)

Generic Api
===========

[](#generic-api)

This Tina4 module is designed to provide a simple api with limited coding, taking advantage of the Tina4 ORM. The ORM class names are used as the api endpoint names. The Api comes with built in security and env configuration.

Installation
------------

[](#installation)

`composer require justblink/generic-api` This will also install Tina4 as a dependency.

Initialize Tina 4

`composer exec tina4 initialize:run`

Setup
-----

[](#setup)

Please add the following to the .env file and set as desired

*Adds to the url between domain name and generic-api routes*

`GENERIC_API_BASE_URL=`

Security
--------

[](#security)

All endpoints are protected with the Tina4 `@secure` route protection. However please ensure that you have added security to your satisfaction.

Simple endpoints
----------------

[](#simple-endpoints)

All ORM objects should have a primary key `id`.

All endpoints can be extended with a prefix set in the .env file by setting the flag GENERIC\_API\_BASE\_URL

Ping is an api verificaion endpoint `/ping`. This can be used to test security and that the api is working.

Get all rows - GET `/[class name]`

Get one row - GET `/[class name]/{id}`

Insert a row - POST `/[class name]`

Partially update a single row - PATCH `/[class name]/{id}`

Partially update a batch of rows - PATCH `/[class name]`

Completely update a single row - PUT `/[class name]/{id}`

Completely update a batch of rows - PUT `/[class name]`

Delete a row - DELETE `/[class name/{id}`

Class names
-----------

[](#class-names)

Class names should be supplied lower case. Complex class names should be separated by "-".

For example: `/my-class-name` will resolve to `MyClassName` in the ORM.

Receiving data
--------------

[](#receiving-data)

All data is sent as JSON objects or array of objects to the endpoints.

PUT, PATCH and DELETE batch endpoints can receive data as an array or single record.

Care should be taken with the PUT endpoints, failure to specify all data could result in empty fields, especially if field defaults are not set.

Sending data
------------

[](#sending-data)

Endpoints will send error messages if things did not go well. All successful calls will result in sending all the data of the modified objects.

Sending the `nodata=1` query parameter with each call, will result in just the affected id's being returned.

Filters
-------

[](#filters)

These filters are available only on the get all rows endpoint. Filters can be added as query parameters in the form

`?field=operator:term`

#### Available operators

[](#available-operators)

```
eq - field that is equal to the term
ne - field that is not equal to the term

```

Concatenation of filters is acceptable

`?field1=operator:term&field2=operator:term`

Validation
----------

[](#validation)

Adding a GenericApiValidation attribute to the ORM will invoke the built in validation. For example this will check if firstName is a string.

```
#[GenericApiValidation('string')]
public firstName;

```

By extending the ValidationHelper one can write custom validations or manipulate values before or after the normal validations, by using the beforeValidate() and afterValidate() functions. Each one has the ability to return if the validation was correct, the value as is (including manipulations), and an error message if required.

Testing
-------

[](#testing)

There is a simple test application built around generic-api and can be found at CrisHigham/generic-api-example. This was built as the base for, and includes, a bruno testing suite and can be used as a base project at your own risk.

Roadmap
-------

[](#roadmap)

- Ability to do validation
- Ability to add defaults
- Standardize the error pattern

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance66

Regular maintenance activity

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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.

###  Release Activity

Cadence

Every ~138 days

Total

5

Last Release

201d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22a5f37894cb65bb93158885de489b4b9952658954003f7fb6c57b6301143c34?d=identicon)[justblink](/maintainers/justblink)

---

Top Contributors

[![CrisHigham](https://avatars.githubusercontent.com/u/62340127?v=4)](https://github.com/CrisHigham "CrisHigham (32 commits)")

### Embed Badge

![Health badge](/badges/justblink-generic-api/health.svg)

```
[![Health](https://phpackages.com/badges/justblink-generic-api/health.svg)](https://phpackages.com/packages/justblink-generic-api)
```

###  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)
