PHP code example of devkussema / semantica-core

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

    

devkussema / semantica-core example snippets


$db = new DatabaseManager($config);

// Default connection
$users = $db->fetch("SELECT * FROM users");

// Specific connection
$products = $db->fetch("SELECT * FROM products", [], 'shop_db');

// Transactions
$db->beginTransaction();
$db->execute("INSERT INTO users (name) VALUES (?)", ['João']);
$db->commit();

$template = new TemplateManager($basePath, $config);

// Switch themes dynamically
$template->setTheme('admin_v1');

// Render with layout
$html = $template->renderWithLayout('users.index', $data);

$router = new Router();

// Named routes with constraints
$router->get('/users/{id}', 'UserController@show')
    ->name('users.show')
    ->where('id', '\d+');

// Route groups
$router->group(['prefix' => 'api'], function($router) {
    $router->get('/status', 'ApiController@status');
});