PHP code example of yidemir / mikro

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

    

yidemir / mikro example snippets


Router\group('/admin', fn() => [
    Router\get('/', 'DashboardController::index'),
    Router\resource('/posts', PostController::class),
    Router\get('/service/status', fn() => Response\json(['status' => true], 200)
], ['AdminMiddleware::handle']);

Router\files('/', __DIR__ . '/sync-directory');

Router\error(fn() => Response\html('Default 404 error', 404));

$products = DB\query('select * from products order by id desc')->fetchAll();
$product = DB\query('select * from products where id=?', [$id])->fetch();

DB\insert('products', ['name' => $name, 'description' => $description]);
$id = DB\last_insert_id();

DB\update('products', ['name' => $newName], 'where id=?', [$id]);
DB\delete('products', 'where id=?', [$id]);
 php
Router\get('/', fn() => Response\view('home'));
html
@View\set('title', 'Page title!');

@View\start('content');
    <p>Secure print: @=$message; or unsecure print @echo $message;</p>
@View\stop();

@View\start('scripts');
    <script src="app.js"></script>
@View\push();

@echo View\render('layout');