1. Go to this page and download the library: Download middag-io/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/ */
middag-io / framework example snippets
use Middag\Framework\Http\Controller\AbstractController;
use Middag\Framework\Http\Inertia\InertiaAdapter;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
final class CourseController extends AbstractController
{
#[Route('/courses', name: 'courses')]
public function index(CourseCatalog $catalog): Response
{
// CourseCatalog is your own domain service, injected by the container.
// No $DB, no $CFG, no host — just your code, described in PHP.
return InertiaAdapter::render('Courses/Index', [
'courses' => $catalog->published(),
]);
}
}
use Middag\Framework\Database\PdoConnectionAdapter;
use Middag\Framework\Persistence\Query\QueryBuilder;
$conn = new PdoConnectionAdapter(new PDO('sqlite::memory:')); // or a mysql:/pgsql: DSN
// The QueryBuilder is immutable. ::on() binds a connection, so the terminals execute.
$courses = QueryBuilder::on($conn, 'courses')
->where('published', true) // equality shortcut
->orderBy('title')
->get(); // array<int, array<string, mixed>>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.