PHPackages                             azen/apify-lumen - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. azen/apify-lumen

ActiveLibrary[HTTP &amp; Networking](/categories/http)

azen/apify-lumen
================

A pretty library to help developers build RESTful APIs lightly, quickly and properly even without writing code

1.4.9.1(5y ago)013MITPHPPHP &gt;=5.6.4

Since May 12Pushed 5y agoCompare

[ Source](https://github.com/tienanhbui/apify-lumen)[ Packagist](https://packagist.org/packages/azen/apify-lumen)[ Docs](https://www.megaads.vn)[ RSS](/packages/azen-apify-lumen/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (1)Versions (52)Used By (0)

Apify
=====

[](#apify)

A pretty library to help developers build `RESTful APIs` lightly, quickly and properly even without writing code.

It's always easy to customize to suit any need such as defining data relationships, authorization, caching, communicating or integrating into other systems.

Features
--------

[](#features)

- Serves RESTful APIs for any MySql database
    - Pagination
    - Sorting
    - Selection
    - Grouping, Having
    - Filtering
    - Relationships
    - Metadata
- Supports Event Bus

Using Apify
-----------

[](#using-apify)

- Apify client for PHP:
- Use HTTP clients like [Postman](https://www.getpostman.com/) to invoke RESTful API calls.
- Combine with [API Gateway](https://github.com/megaads-vn/api-gateway) is also recommended to build a completely development environment for microservice.

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

[](#installation)

Apify is packed as a composer package. So it's installed quickly in 2 steps

1. Require the composer package

    `composer require megaads/apify`
2. Register the provider:

    `Megaads\Apify\ApifyServiceProvider`

System requirements
-------------------

[](#system-requirements)

- PHP: &gt;= 5.6
- Laravel/ Lumen Framework: 5.4.\*
- MySQL
- Message queue server: optional

API Overview
------------

[](#api-overview)

HTTP MethodAPI URLDescriptionFor exampleGET`/api/entity`List all records of table that match the query`curl http://my-api.com/api/user?filters=age>20`GET`/api/entity/:id`Retrieve a record by primary key :id`curl http://my-api.com/api/user/123`POST`/api/entity`Insert a new record, bulk inserting is also avaiable`curl -X POST http://my-api.com/api/user -d '[{"username":"user1", "age":"20"},{"username":"user2", "age":"25"}]' -H "Content-Type: application/json"`PUT`/api/entity/:id`Replaces existed record with new one`curl -X PUT http://my-api.com/api/user/123 -d '{"id":"123", "username":"user1", "age":"20"}' -H "Content-Type: application/json"`PATCH`/api/entity/:id`Update record element by primary key`curl -X PATCH http://my-api.com/api/user/123 -d '{"age":"21"}' -H "Content-Type: application/json"`DELETE`/api/entity/:id`Delete a record by primary key`curl -X DELETE http://my-api.com/api/user/123`DELETE`/api/entity`Delete bulk records that match the query`curl -X DELETE http://my-api.com/api/user?filters=age>100`POST`/api/upload`Upload a file`curl -X POST http://my-api.com/api/upload -H "Content-Type: multipart/form-data" -F "data=@song.mp3"`Pagination
----------

[](#pagination)

ParameterRequiredDefaultDescriptionpage\_idNo0Page index, start at 0page\_sizeNo50Number of rows to retrieve per page```
/api/post?page_id=2&page_size=20

```

Sorting
-------

[](#sorting)

Order by multiple columns using **`sorts`** parameter

### Sort ascending

[](#sort-ascending)

```
/api/post?sorts=user_id

```

### Sort descending

[](#sort-descending)

```
/api/post?sorts=-created_at

```

### Sort by multiple columns

[](#sort-by-multiple-columns)

```
/api/post?sorts=user_id,-created_at

```

Selection
---------

[](#selection)

Select columns from the records using **`fields`** parameter. SQL aggregate functions such as `COUNT`, `MAX`, `MIN`, `SUM`, `AVG`, SQL aliases are also available

```
/api/post?fields=id,content,user_id,sum(view_count) as view_sum

```

Group By
--------

[](#group-by)

Group the result-set by one or more columns using **`groups`** parameter and combine with aggregate functions using `Selection`

```
/api/post?fields=user_id,sum(view_count)&groups=user_id

```

Filtering
---------

[](#filtering)

OperatorConditionFor example=Equal to/api/post?filters=user\_id=1!=Not equal/api/post?filters=user\_id!=1&gt;Greater/api/post?filters=user\_id&gt;1&gt;=Greater or equal/api/post?filters=user\_id&gt;=1&lt;Less/api/post?filters=user\_id&lt;1&lt;=Less or equal/api/post?filters=user\_id&lt;=1={}In/api/post?filters=user\_id={1;2;3}!={}Not in/api/post?filters=user\_id!={1;2;3}=\[\]Between/api/post?filters=user\_id=\[1;20\]!=\[\]Not between/api/post?filters=user\_id!=\[1;20\]~Like/api/post?filters=title~hello!~Not like/api/post?filters=title!~helloApify supports filtering records based on more than one `AND`, `NOT` condition by using comma. For example:

```
/api/post?filters=user_id=1,status={enabled;pending},tile~hello,view_count!=null

```

Complex conditions that combine `AND`, `OR` and `NOT` will be available soon.

Entity conventions
------------------

[](#entity-conventions)

Apify works by a simple mechanism, looking for a model class that correspond to the API entity, otherwise the API entity will be matched to a suitable DB table. That means no model class is required to create, do it only in the case of defining relationships, customizing.

So API entity name should follow one of the conventions:

- The API entity name is the same as a model class name
- Or the API entity name in `snake_case` that correspond to a model class with the name in `CamelCase`
- Or the API entity name is the same as a DB table name

Relationships
-------------

[](#relationships)

Apify is packed into a `Laravel`/ `Lumen` package so relationships also are defined as methods on `Eloquent` model classes.

See Laravel docs for details:

Let's consider the following relationship definations:

- A `Nation` has many `City` (one-to-many relationship)

```
namespace App\Models;
class Nation extends \Apify\Models\BaseModel {
    protected $table = 'location_nation';
    public function cities() {
        return $this->hasMany('App\Models\City', 'nation_id', id);
    }
}
```

- A `City` belongs to a `Nation` (many-to-one relationship)
- A `City` has many `District` (one-to-many relationship)

```
namespace App\Models;
class City extends \Apify\Models\BaseModel {
    protected $table = 'location_city';
    public function nation() {
        return $this->belongsTo('App\Models\Nation', 'nation_id');
    }
    public function districts() {
        return $this->hasMany('App\Models\District', 'city_id', id);
    }
}
```

- A `District` belongs to a `City` (many-to-one relationship)

```
namespace App\Models;
class District extends \Apify\Models\BaseModel {
    protected $table = 'location_district';
    public function city() {
        return $this->belongsTo('App\Models\City', 'city_id');
    }
}
```

### Selection on relationships

[](#selection-on-relationships)

Apify provides the ability to embed relational data into the results using `embeds` parameter

For example

```
/api/nation?embeds=cities

```

```
/api/city?embeds=nation,districts

```

```
/api/district?embeds=city

```

Even nested relationships

```
/api/nation?embeds=cities.districts

```

```
/api/district?embeds=city.nation

```

### Filtering on relationships

[](#filtering-on-relationships)

```
/api/city?filters=nation.location_code=EU,districts.name~land

```

Metric
------

[](#metric)

### metric=get (by default): Retrieve all records that match the query

[](#metricget-by-default-retrieve-all-records-that-match-the-query)

```
/api/post

```

or

```
/api/post?metric=get

```

Response format

```
{
    "meta": {
        "has_next": true,
        "total_count": 100,
        "page_count": 2,
        "page_size": 50,
        "page_id": 0
    },
    "result": [],
    "status": "successful"
}
```

### metric=first: Retrieve the first record that matchs the query

[](#metricfirst-retrieve-the-first-record-that-matchs-the-query)

```
/api/post?metric=first

```

Response format

```
{
    "result": {},
    "status": "successful"
}
```

### metric=count: Retrieve the number of records that match the query

[](#metriccount-retrieve-the-number-of-records-that-match-the-query)

```
/api/post?metric=count

```

Response format

```
{
    "result": 50,
    "status": "successful"
}
```

### metric=increment/ decrement: Provides convenient methods for incrementing or decrementing the value of a selected column

[](#metricincrement-decrement-provides-convenient-methods-for-incrementing-or-decrementing-the-value-of-a-selected-column)

```
/api/post?metric=increment&fields=view_count

```

Response format

```
{
    "result": 1,
    "status": "successful"
}
```

Event Bus
---------

[](#event-bus)

Is being updated ...

.env configurations
-------------------

[](#env-configurations)

KeyDefault valueDescriptionAPIFY\_PREFIX\_URL`api`API URL prefixAPIFY\_MODEL\_NAMESPACE`App\Models`Models namespaceAPIFY\_UPLOAD\_PATH`/home/upload`Upload pathAPIFY\_MQ\_ENABLE`false`Enable / Disable Message queue (Event Bus)APIFY\_MQ\_HOSTMessage queue server hostAPIFY\_MQ\_PORTMessage queue server portAPIFY\_MQ\_USERNAMEMessage queue authentication - usernameAPIFY\_MQ\_PASSWORDMessage queue authentication - passwordAPIFY\_MQ\_EXCHANGE`apify`Message queue exchange nameAuthenticate Apify &amp; authorize Apify?
-----------------------------------------

[](#authenticate-apify--authorize-apify)

Read docs here :

License
-------

[](#license)

The Apify is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

Contact us/ Instant feedback
----------------------------

[](#contact-us-instant-feedback)

Email:

Skype: phult.bk

If you find a bug, please report it [here on Github](https://github.com/megaads-vn/apify/issues).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 69.3% 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 ~18 days

Recently: every ~48 days

Total

51

Last Release

2014d ago

Major Versions

0.9.45 → 1.0.02018-05-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/4e12bde1d6827272172c074c59a6d34e2f39f874d56488bd30eee1827fc00401?d=identicon)[tienanhbui](/maintainers/tienanhbui)

---

Top Contributors

[![phult](https://avatars.githubusercontent.com/u/4711640?v=4)](https://github.com/phult "phult (70 commits)")[![lapdx](https://avatars.githubusercontent.com/u/5915409?v=4)](https://github.com/lapdx "lapdx (11 commits)")[![quanbka](https://avatars.githubusercontent.com/u/13042109?v=4)](https://github.com/quanbka "quanbka (11 commits)")[![tienanhbui](https://avatars.githubusercontent.com/u/22376801?v=4)](https://github.com/tienanhbui "tienanhbui (4 commits)")[![tuananhzippy](https://avatars.githubusercontent.com/u/13558393?v=4)](https://github.com/tuananhzippy "tuananhzippy (3 commits)")[![phamanhtuan90](https://avatars.githubusercontent.com/u/7715106?v=4)](https://github.com/phamanhtuan90 "phamanhtuan90 (2 commits)")

---

Tags

apilaravelrestlumenwebserviceMicroserviceapi-generator

### Embed Badge

![Health badge](/badges/azen-apify-lumen/health.svg)

```
[![Health](https://phpackages.com/badges/azen-apify-lumen/health.svg)](https://phpackages.com/packages/azen-apify-lumen)
```

###  Alternatives

[megaads/apify

A pretty library to help developers build RESTful APIs lightly, quickly and properly even without writing code

151.7k](/packages/megaads-apify)[wn/lumen-generators

A collection of generators for Lumen and Laravel 5.

350205.3k2](/packages/wn-lumen-generators)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[noitran/opendox

OpenApi(Swagger) 3.0 package for Lumen 5.5+ and Laravel 5.5+ with REDOC UI and SwaggerUI 3

2313.9k](/packages/noitran-opendox)[rap2hpoutre/jacky

Opinionated REST JSON HTTP API client for laravel

174.4k](/packages/rap2hpoutre-jacky)[laragear/api-manager

Manage multiple REST servers to make requests in few lines and fluently.

161.8k](/packages/laragear-api-manager)

PHPackages © 2026

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