PHP code example of samaphp / microapp
1. Go to this page and download the library: Download samaphp/microapp 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/ */
samaphp / microapp example snippets
MicroApp\MicroApp;
$app = new MicroApp();
$app->loadRoutesFrom(__DIR__ . '/src/Controller', 'App\\Controller');
$app->dispatch();
namespace App\Controller;
use MicroApp\MicroApp;
class HomeController
{
public function routes(MicroApp $app): void
{
$app->get('/home', [$this, 'index']);
}
public function index(): void
{
echo 'Hello from HomeController';
}
}