1. Go to this page and download the library: Download mrpc/pramnosframework 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/ */
mrpc / pramnosframework example snippets
// public/index.php
root app directory
define('ROOT', dirname(__DIR__));
// Define start point for performance tracking
define('SP', microtime(true));
// Create an application instance
$app = new Pramnos\Application\Application();
// Initialize the application
$app->init();
// Execute the application
$app->exec();
// Render the output
echo $app->render();
namespace MyApp\Controllers;
class WelcomeController extends \Pramnos\Application\Controller
{
public function __construct(?\Pramnos\Application\Application $application = null)
{
// Define public actions (no authentication nction display()
{
$view = $this->getView('Welcome');
$doc = \Pramnos\Framework\Factory::getDocument();
$doc->title = 'Welcome to Pramnos Framework';
$this->application->addBreadcrumb('Home', sURL);
return $view->display('welcome');
}
}
// Using the Pramnos database pattern
$sql = $this->application->database->prepareQuery(
"SELECT * FROM users WHERE email = %s AND status = %d",
$email,
$status
);
$result = $this->application->database->query($sql);
// Single record
if ($result->numRows > 0) {
$user = $result->fields; // Direct access to associative array
}
// Multiple records
$users = [];
while ($result->fetch()) {
$users[] = $result->fields;
}
namespace MyApp\Api\Controllers;
class UsersController extends \Pramnos\Application\Controller
{
public function display()
{
// GET /api/users
$users = $this->getModel('User')->getList();
return $this->response(['users' => $users]);
}
public function postCreateUser()
{
// POST /api/users
$data = $this->getRequestData();
$user = $this->getModel('User');
$user->create($data);
return $this->response(['user' => $user->getData()], 201);
}
}
// Using the cache system
$cache = \Pramnos\Cache\Cache::getInstance('user_data', 'user', 'redis');
// Save data
$cache->save($userData, $userId);
// Load data
$userData = $cache->load($userId);
// Clear category
$cache->clear('user');