PHP code example of ycrao / tinyme

1. Go to this page and download the library: Download ycrao/tinyme 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/ */

    

ycrao / tinyme example snippets


use flight\Cache;

$app = Flight::app();
// Register cache
$app->register('cache', Cache::class, [__DIR__ . '/../storage/cache']);

$app->cache()->set('hello', 'world', 60 * 60);
$world = $app->cache()->get('hello');

use Monolog\Logger;
use Monolog\Level;
use Monolog\Handler\StreamHandler;

$app = Flight::app();
// Register logger
$app->register('logger', Logger::class, ['tinyme'], function($logger) {
    $logPath = __DIR__ . '/../storage/logs/app.log';
    $logger->pushHandler(new StreamHandler($logPath, Level::Debug));
});

use Medoo\Medoo;
use app\utils\Helper;

$app = Flight::app();

// Register database
$app->register('db', Medoo::class, [
    [
        'type' => 'mysql',
        'host' => Helper::env('DB_HOST', 'localhost'),
        'port' => Helper::env('DB_PROT', 3306),
        'database' => Helper::env('DB_DATABASE', 'tinyme'),
        'username' => Helper::env('DB_USERNAME', 'root'),
        'password' => Helper::env('DB_PASSWORD', 'root'),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
    ]
]);

$page = $app->db()->get('tm_page', '*', [
    'id' => 1
]);