PHP code example of pygroos / moant

1. Go to this page and download the library: Download pygroos/moant library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pygroos / moant example snippets




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
        );
    } 
}

php task.php [Class] [Method] [(optional) param ...]