All Projects → ycrao → Tinyme

ycrao / Tinyme

Licence: mit
A tiny php framework based on flight and medoo with restful api service

Projects that are alternatives of or similar to Tinyme

Api Strategy
Equinor API Strategy
Stars: ✭ 56 (+100%)
Mutual labels:  api, rest, restful-api
Apidoc
RESTful API 文档生成工具,支持 Go、Java、Swift、JavaScript、Rust、PHP、Python、Typescript、Kotlin 和 Ruby 等大部分语言。
Stars: ✭ 785 (+2703.57%)
Mutual labels:  api, rest, restful-api
Openapi Generator
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
Stars: ✭ 10,634 (+37878.57%)
Mutual labels:  api, rest, restful-api
Appy Backend
A user system to bootstrap your app.
Stars: ✭ 96 (+242.86%)
Mutual labels:  api, rest, restful-api
Appkernel
API development made easy: a smart Python 3 API framework
Stars: ✭ 152 (+442.86%)
Mutual labels:  api, rest, restful-api
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (+75%)
Mutual labels:  api, rest, restful-api
Ngx Restangular
Restangular for Angular 2 and higher versions
Stars: ✭ 787 (+2710.71%)
Mutual labels:  api, rest, restful-api
Digital Restaurant
DDD. Event sourcing. CQRS. REST. Modular. Microservices. Kotlin. Spring. Axon platform. Apache Kafka. RabbitMQ
Stars: ✭ 222 (+692.86%)
Mutual labels:  rest, restful-api, demo
Node Express Postgresql Sequelize
Node.js, Express.js, Sequelize.js and PostgreSQL RESTful API
Stars: ✭ 148 (+428.57%)
Mutual labels:  api, rest, restful-api
Node Express Mongoose Passport Jwt Rest Api Auth
Node, express, mongoose, passport and JWT REST API authentication example
Stars: ✭ 146 (+421.43%)
Mutual labels:  api, rest, restful-api
Open Rest
Standard rest server, Base on restify and sequelize
Stars: ✭ 136 (+385.71%)
Mutual labels:  api, rest, restful-api
Graphql2rest
GraphQL to REST converter: automatically generate a RESTful API from your existing GraphQL API
Stars: ✭ 181 (+546.43%)
Mutual labels:  api, rest, restful-api
Proteus
Lean, mean, and incredibly fast JVM framework for web and microservice development.
Stars: ✭ 178 (+535.71%)
Mutual labels:  api, rest, restful-api
Http Fake Backend
Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 253 (+803.57%)
Mutual labels:  api, rest, restful-api
Rest Api Nodejs Mongodb
A boilerplate for REST API Development with Node.js, Express, and MongoDB
Stars: ✭ 672 (+2300%)
Mutual labels:  api, rest
Apistar
The Web API toolkit. 🛠
Stars: ✭ 5,605 (+19917.86%)
Mutual labels:  api, rest
Cortex
Cortex: a Powerful Observable Analysis and Active Response Engine
Stars: ✭ 676 (+2314.29%)
Mutual labels:  api, rest
Just Api
💥 Test REST, GraphQL APIs
Stars: ✭ 768 (+2642.86%)
Mutual labels:  api, rest
Postgrest Starter Kit
Starter Kit and tooling for authoring REST API backends with PostgREST
Stars: ✭ 657 (+2246.43%)
Mutual labels:  api, rest
Koa2 Api Scaffold
一个基于Koa2的轻量级RESTful API Server脚手架。
Stars: ✭ 694 (+2378.57%)
Mutual labels:  api, restful-api

TinyMe

Latest Stable Version Latest Unstable Version License Total Downloads

A tiny php framework based on flight and medoo.

IntroductionPage | 简体中文读我

Installation

Just like Laravel installation, set public directory as server root path in vhost.conf and using composer to install or update packages and so on. You can do these in your terminal like below:

//using git
git clone https://github.com/ycrao/tinyme.git tinyme
//or using composer, but skip `composer install` command below
composer create-project --prefer-dist ycrao/tinyme tinyme
cd tinyme
cp .env.example .env
vim .env
composer install
cd app
chmod -R 755 storage
php -S 127.0.0.1:9999 -t public

You can view this project page by typing http://127.0.0.1:9999 url in your browser.

API Service

Please import sql\tinyme.sql to your local MySQL database, then modify .env file configuration.

Route

Method Route or URI Note
post /api/login Get access-token by logining account.
get /api/pages Get current user pages with pagination.
post /api/page Create a new page.
get /api/page/@id Get page by specified id.
put /api/page/@id Update page by specified id.
delete /api/page/@id Delete page by specified id.

API error code

Code Note
500 fail or error.
401 (Unauthorized) access token already expired.
403 (Forbidden) illegal or incorrect credentials.
404 (Not Found) api or route not existed.
200 (OK) success.

post api/login

Using email and password to login and get access token. Please recall login api when token is expired, do not call this api frequently when old token(s) not expired.

Request Example

curl -X POST http://127.0.0.1:9999/api/login --data "[email protected]&password=123456"

Response Example

Using 200 as code when success.

{
    "code": 200,
    "msg": "OK",
    "data": {
        "uid": "1",
        "token": "TVC66rtXnv7pw3jge4EtyC7qtyKKPxjjGyVUi4K2D",
        "expire_at": 1510233022
    }
}

Using non-2xx (403500 etc) digital when fail or error.

{
    "code": 403,
    "msg": "illegal or incorrect credentials",
    "data": []
}

get api/pages

Get current user pages with pagination.

Request Example

curl http://127.0.0.1:9999/api/pages -H "AUTHORIZATION: Bearer TVC66rtXnv7pw3jge4EtyC7qtyKKPxjjGyVUi4K2D"

# with page
curl http://127.0.0.1:9999/api/pages?page=2&per_page=2 -H "AUTHORIZATION: Bearer TVC66rtXnv7pw3jge4EtyC7qtyKKPxjjGyVUi4K2D"

Response Example

{
    "code": 200,
    "msg": "OK",
    "data": {
        "total": 2,
        "per_page": 2,
        "current_page": 2,
        "next_page_url": "/api/pages/?page=3&per_page=2",
        "prev_page_url": "/api/pages/?page=1&per_page=2",
        "from": "1",
        "to": "1",
        "data": [
            {
                "id": "1",
                "content": "# Hello world\n\nThis is a demo page.",
                "created_at": "2017-11-09 13:54:39",
                "updated_at": "2017-11-09 13:54:39"
            }
        ]
    }
}

post api/page

Create a new page.

Request Example

# POST raw data (in `json` format)
curl -X POST http://127.0.0.1:9999/api/page --data '{"content":"# Hello world\n\nThis is another demo page."}' -H "AUTHORIZATION: Bearer TVC66rtXnv7pw3jge4EtyC7qtyKKPxjjGyVUi4K2D"

# POST data (in form string)
curl -X POST http://127.0.0.1:9999/api/page --data "content=# Hello world\n\nThis is another demo page." -H "AUTHORIZATION: Bearer TVC66rtXnv7pw3jge4EtyC7qtyKKPxjjGyVUi4K2D"

Response Example

{
    "code":200,
    "msg":"OK",
    "data":{
        "result":"create success!",
        "view_url":"/api/page/4"
    }
}

get api/page/@id

Get page by specified id.

Request Example

curl http://127.0.0.1:9999/api/page/4 -H "AUTHORIZATION: Bearer TVC66rtXnv7pw3jge4EtyC7qtyKKPxjjGyVUi4K2D"

Response Example

{
    "code":200,
    "msg":"OK",
    "data":{
        "id":"4",
        "uid":"1",
        "content":"# Hello world\n\nThis is another demo page.",
        "created_at":"2017-11-09 20:36:52",
        "updated_at":"2017-11-09 20:36:52"
    }
}

put api/page/@id

Update page by specified id.

Request Example

# PUT raw data (in `json` format)
curl -X PUT http://127.0.0.1:9999/api/page/4 --data '{"content":"# Demo\n\nThis is another demo page."}' -H "AUTHORIZATION: Bearer TVC66rtXnv7pw3jge4EtyC7qtyKKPxjjGyVUi4K2D"

# hijack PUT method by passing `_method=put` parameter with POST
curl -X POST http://127.0.0.1:9999/api/page/4 --data "_method=put&content=# Demo\n\nThis is another demo page." -H "AUTHORIZATION: Bearer TVC66rtXnv7pw3jge4EtyC7qtyKKPxjjGyVUi4K2D"

Response Example

{
    "code":200,
    "msg":"OK",
    "data":{
        "result":"update success!"
    }
}

delete /api/page/@id

Delete page by specified id.

Request Example

# DELETE
curl -X DELETE http://127.0.0.1:9999/api/page/4 -H "AUTHORIZATION: Bearer TVC66rtXnv7pw3jge4EtyC7qtyKKPxjjGyVUi4K2D"

# hijack DELETE method by passing `_method=delete` parameter with POST
curl -X POST http://127.0.0.1:9999/api/page/4 --data "_method=delete" -H "AUTHORIZATION: Bearer TVC66rtXnv7pw3jge4EtyC7qtyKKPxjjGyVUi4K2D"

Response Example

{
    "code":200,
    "msg":"OK",
    "data":{
        "result":"delete success!"
    }
}

Documentation

Kernel

based on mikecao/flight , official website : http://flightphp.com/ , https://github.com/mikecao/flight .

Cache

if (Flight::cache('data')->contains('foo')) {
    $unit = Flight::cache('data')->fetch('foo');
} else {
    $bar = 'bar cache';
    Flight::cache('data')->save('foo', $bar);
}

based on doctrine/cache , official website : http://docs.doctrine-project.org/en/latest/reference/caching.html , https://github.com/doctrine/cache .

Log

$logger = Flight::log()->debug('debug log');

based on katzgrau/klogger , official website : https://github.com/katzgrau/KLogger .

Database and Model

Flight::model('Page')->getPageByID(1);
Flight::db()->get('tm_page', '*', [
            'id' => 1
            ]);

based on catfan/medoo , official website : https://github.com/catfan/medoo , http://medoo.in/doc .

Reference

flight-app-demo

License

The TinyMe framework is open-sourced software licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].