PHPackages                             legionlab/restapi - 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. legionlab/restapi

ActiveLibrary[API Development](/categories/api)

legionlab/restapi
=================

RestAPI LegionLab PHP

0.22(9y ago)019MITS

Since Dec 18Compare

[ Source](https://github.com/leonardovilarinho/restapi)[ Packagist](https://packagist.org/packages/legionlab/restapi)[ RSS](/packages/legionlab-restapi/feed)WikiDiscussions Synced yesterday

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

legionlab/restapi
=================

[](#legionlabrestapi)

Rest API PHP for apps mobiles

---

Install command:

```
composer create-project legionlab/restapi your-project

```

---

Configure your ambient, in file setups.php:

```
Settings::set('api_url', 'url_from_project');

Settings::set("dbhost", "url_db");

Settings::set("dbuser", "user_db");

Settings::set("dbpassword", "password_db");

Settings::set("default_dbname", "name_db");

```

---

Examples
--------

[](#examples)

### GET

[](#get)

```
$app = new \LegionLab\Rest\Core();

$app->get('/get', function () {
    echo 'Welcome to Rest API, by GET';
});

$app->get('/get', function ($data) {
    echo 'Welcome to Rest API, '.$data['name'].', by GET';
}, [ 'name' => 'any' ]);

```

### POST

[](#post)

```
$app = new \LegionLab\Rest\Core();

$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST['name'] = 'user';
$_POST['age'] = 20;

$app->post('/post', function () {
    echo 'Welcome to Rest API, by POST';
});

$app->post('/post', function ($data) {
    try {

        (new Client())->fill($data)->insert();
        echo 'Welcome to Rest API, by POST, client saved';

    } catch (Exception $e) {
        echo $e->getMessage().'';
    }
}, [ 'name' => 'any', 'age' => 'int' ]);

```

### PUT

[](#put)

```
$app = new \LegionLab\Rest\Core();

$app->put('/put', function($data) {
    try {
        $client = new Client();
        $client->fill($data);
        $client->get();
        $client->fill($data);
        $client->update();
        echo json_encode(['message' => 'The user '.$data['id'].' edited, by DELETE' ]);

    } catch (Exception $e) {
        echo json_encode(['message' => $e->getMessage().'' ]);
    }

}, [ 'id' => 'int', 'age' => 'int']);

```

### DELETE

[](#delete)

```
$app = new \LegionLab\Rest\Core();

$app->delete('/delete', function($data) {
    try {
        $criteria = \LegionLab\Utils\CriteriaBuilder::create()
            ->tables('clients')->_and('id', '=', $data['id']);

        (new Client())->delete($criteria);
        echo json_encode(['message' => 'The user '.$data['id'].' deleted, by DELETE' ]);

    } catch (Exception $e) {
        echo json_encode(['message' => $e->getMessage().'' ]);
    }
}, [ 'id' => 'int' ]);

```

---

### Simulate PUT and DELETE with cURL

[](#simulate-put-and-delete-with-curl)

### PUT

[](#put-1)

```
$app = new \LegionLab\Rest\Core();

$app->get('/sendput', function() {
    $curl = curl_init(Settings::get('api_url') . "/put");

    $data = array(
        'id' => 2,
        'age' => 90
    );

    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));

    $response = curl_exec($curl);
    curl_close($curl);

    if (!$response)
        die("Connection Failure.n");
    else
        var_dump(json_decode($response));
});

```

### DELETE

[](#delete-1)

```
$app = new \LegionLab\Rest\Core();

$app->get('/senddelete', function() {
    $curl = curl_init(Settings::get('api_url') . "/delete");

    $data = array(
        'id' => '2'
    );

    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));

    $response = curl_exec($curl);
    curl_close($curl);

    if (!$response)
        die("Connection Failure.n");
    else
        var_dump(json_decode($response));
});

```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

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 ~0 days

Total

2

Last Release

3483d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12480135?v=4)[Leonardo Vilarinho](/maintainers/LeonardoVilarinho)[@leonardovilarinho](https://github.com/leonardovilarinho)

### Embed Badge

![Health badge](/badges/legionlab-restapi/health.svg)

```
[![Health](https://phpackages.com/badges/legionlab-restapi/health.svg)](https://phpackages.com/packages/legionlab-restapi)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M19](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

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