PHP code example of tflori / riki-framework

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

    

tflori / riki-framework example snippets




ronment = new \Riki\Environment(realpath(__DIR__));
$application = new \App\Application($environment);

return $application;

$environment = new \Riki\Environment(realpath(__DIR__));
$environment->loadEnvironment();

$cacheDir = $environment->cachePath();
$value = $environment->get('APP_ENV', 'local');



return [
    'name' => 'My App',
    'log' => [
        'level' => env('LOG_LEVEL', 'WARNING'),
    ],
];

$config = \Riki\Application::config();
$name = $config->get('name');
$level = $config->get('log.level', 'WARNING');

$config->set('log.level', 'INFO');
$config->push('features.enabled', 'new-feature');

class App extends \Riki\Application
{
    protected function initDependencies()
    {
        $this->instance('logger', new \Psr\Log\NullLogger());
        $this->alias('logger', \Psr\Log\LoggerInterface::class);
    }
}

$environment = new \Riki\Environment(realpath(__DIR__));
return new \App\App($environment);

class HttpKernel extends \Riki\Kernel
{
    public function handle()
    {
        $router = \Riki\Application::app()->get('router');
        return $router->dispatch($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
    }
}

$level = env('LOG_LEVEL', 'WARNING');



class MyKernel extends \Riki\Kernel
{
    public function handle()
    {
        echo 'Hello world!' . PHP_EOL;
        return 0;
    }
}



$app = run(new MyKernel($app));
if ($ret > 0) {
    exit($ret);
}