An open API service indexing awesome lists of open source software.

https://github.com/pluveto/cirno

Cirno is a light-weight php RESTful api framework
https://github.com/pluveto/cirno

framwork php restful-api

Last synced: about 1 year ago
JSON representation

Cirno is a light-weight php RESTful api framework

Awesome Lists containing this project

README

          

# Cirno

Cirno-php is a light-weight php api framework for rapid development, based on Flight and Medoo, with apiDoc support.














## Features

Cirno-php helps create api with many **AUTOMATICAL** operations, which saves your massive time.

1. Auto generate **http methods, routes** into files.
2. Auto **parameters** basic filte.
3. Auto **user permissions** filte

Let's take an example:

Create a file `src/Api/Calculator.php`

```php
request()->query->num;
\App::$api->json([
"result" => $num * $num
]);
}
}
```

And execute:

```shell
$ php generator.php run
```

You can see some files generated:

```php
//file: src/common/route.php
[
'param' => [
'num' => [
'type' => 'integereger',
'min' => 0,
'max' => 200,
'required' => true,
],
],
],
];
```

```php
//file: src/common/permission.php
'none',
];
```

And then we go to `http://127.0.0.1:8080/calc/sqrt?num=10`

We got:

```json
{
"result": 100
}
```

What if `http://127.0.0.1:8080/calc/sqrt?num=1000`?

```json
{
"message": "Parameter `num` is expected to be less than 200. "
}
```

And what if `http://127.0.0.1:8080/calc/sqrt?ss=1000`?

```json
{
"message": "Mising required parameter."
}
```

And `http://127.0.0.1:8080/calc/sqrt?num=`?

```json
{
"message": "Parameter `num` is given but it has empty value."
}
```

As you can see, what you need to do is just write API code. API comments will be parsed.