moaik/moant

Micro framework powered by slim

Maintainers

Details

github.com/moaik/moant

Source

Issues

Installs: 7

Dependents: 0

Suggesters: 0

Security: 0

Stars: 12

Watchers: 0

Forks: 0

Type:project

v1.0.6 2020-04-09 04:37 UTC

README

687474703a2f2f707967726f6f732d6769746875622e6f73732d636e2d6265696a696e672e616c6979756e63732e636f6d2f616e742e7376673f457870697265733d31353438343035343739264f53534163636573734b657949643d544d502e4151486e787761614c734c614d4649794762516d59684431634c5671573842326d636f725a316c4734774457385861417375616e4f5a4c6433523036414441744168554169363358375238586a36717531397372764a424671574a7a687034434646476a6578316f7064585767764476394371754a5834565a7a7545265369676e61747572653d646d6767596a786d4630774458505630523350584e345a74375041253344

68747470733a2f2f706f7365722e707567782e6f72672f707967726f6f732f6d6f616e742f762f737461626c65 68747470733a2f2f706f7365722e707567782e6f72672f707967726f6f732f6d6f616e742f646f776e6c6f616473 License

Introduction

Moant is a php micro framework powered by slim.Used for easy and quick development api.
Moant have the following characteristics:

  • restful api route
  • flexible api version control
  • customize package
  • php cli command
  • ......

Installation

composer create-project pygroos/moant your-app '1.0.*' --prefer-dist -vvv

Example

  • Route
$app->get('/', '\App\Api\DemoApi:test');
  • Config
APP_DEBUG=true
TIMEZONE=Asia/Shanghai

# Database config
# [required]
DB_TYPE=mysql
DB_NAME=test
DB_HOST=127.0.0.1
DB_USERNAME=root
DB_PASSWORD=
# [optional]
DB_PORT=
DB_CHARSET=
DB_PREFIX=

# Redis config
REDIS_SCHEME=tcp
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
  • Api demo
<?php

namespace App\Api;

use App\Services\DB;
use App\Services\Redis;
use App\Services\Logger;

class DemoApi extends BaseApi
{
    public function test()
    {
        // Get Param Example
        $param = $this->request->getParam('param', 0);
	
        // DB Service Example
        $db = DB::getInstance();
        $arrUser = $db->select('users', ['username']);

        // Redis Service Example
        $redis = Redis::getInstance();
        $redis->setex('redis_key', 3600, json_encode($arrUser));

        // Logger Service Example
        Logger::add(
            'name',
            [
                $this->request->getUri(),
                $this->request->getMethod()
            ]
        );
		
        return $this->outPut(
            200,
            'success',
            ['project' => 'Moant Framework'],
            $this->version
        );
    } 
}
  • Command
php task.php [Class] [Method] [(optional) param ...]

In use package

Video tutorial

http://study.163.com/course/introduction/1004712047.htm