pygroos / moant
Micro framework powered by slim
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 0
Forks: 0
Open Issues: 3
Type:project
Requires
- php: >=5.5.0
- catfan/medoo: ^1.4
- guzzlehttp/guzzle: ^6.3
- monolog/monolog: ^1.23
- nette/mail: ^3.0
- predis/predis: ^1.1
- slim/slim: ^3.8
- vlucas/phpdotenv: ^2.4
Requires (Dev)
- phpunit/phpunit: ^6.4
This package is auto-updated.
Last update: 2025-04-16 10:41:41 UTC
README
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 ...]