A tiny, beginner‑friendly PHP micro‑framework for learning by doing.
- Plain PHP controllers and views
- Raw SQL (SQLite by default; Postgres/MySQL ready)
- Minimal helpers (Router, DB, Session, CSRF)
- Optional Tailwind + DaisyUI + Vite + Alpine.js
composer create-project ibnuafdel/daltphp my-app "^0.1@alpha"
cd my-appWhat happens automatically:
.envis created with SQLite defaults (no DB setup required)storage/logsis prepared- If Node is available, post-create may install/build assets (optional)
php artisan serve- Starts the PHP built-in server on a free port (8000, 8001, ...)
- Uses
public/router.phpso static files (e.g./favicon.svg,/css/*,/js/*) are served correctly - Keep the terminal open to see request logs
Optional (for HMR/live reload):
npm ci
npm run devIf Vite dev server or manifest is not available, views fall back to static assets under /js/app.js, /js/app.css, or /css/style.css.
public/ # index.php (front controller), router.php, favicon.svg
routes/routes.php # define routes
Http/controllers/ # your plain PHP controllers
config/ # app.php, database.php (SQLite default)
resources/
views/
layouts/ # head.php, nav.php, footer.php
status/ # 403.php, 404.php, 500.php
js/app.js # Vite entry (imports ../css/input.css)
css/input.css # Tailwind entry
framework/
Core/ # router, db, session, middleware, helpers
examples/ # auth demo (optional)
database/migrations/ # migrations (Illuminate Database)
storage/logs/.gitkeep # logs dir
artisan # minimal CLI: serve/migrate/etc
- Add routes in
routes/routes.php:
$router->get('/', 'welcome.php');- Create a controller in
Http/controllers/welcome.php:
<?php
view('welcome.view.php');- Views live in
resources/views/.
- Route params:
/posts/{id}→ available as$_GET['id'] - Methods:
$router->get(),post(),patch(),delete() - Middleware on a route:
$router->post('/session', 'session/store.php')->only(['guest','csrf']);Built-in keys: csrf, auth, guest.
SQLite by default (zero setup). To switch to PostgreSQL or MySQL, edit .env.
SQLite (default):
DB_DRIVER=sqlite
DB_DATABASE=database/app.sqlitePostgreSQL:
DB_DRIVER=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_NAME=dalt_php_app
DB_USERNAME=postgres
DB_PASSWORD=MySQL:
DB_DRIVER=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_NAME=dalt_php_app
DB_USERNAME=root
DB_PASSWORD=Migrations (powered by illuminate/database):
php artisan migrate # run migrations
php artisan migrate:fresh # drop sqlite DB and re-run
php artisan make:migration postsInstall the demo (register/login/logout):
php artisan example:install authWhat it does:
- Copies demo controllers and views into your app
- Appends auth routes to
routes/routes.php - Shows Login/Register or Logout links in the header
- Set
APP_DEBUG=truein.envfor a simple stack trace on errors - In production, errors are logged to
storage/logs/app.logand a cleanresources/views/status/500.phpis shown - Status pages:
resources/views/status/{403,404,500}.php
- Vite + Tailwind + DaisyUI + Alpine.js are prewired
- Entry:
resources/js/app.js(imports../css/input.css) - In views, assets are included via
<?= vite('resources/js/app.js') ?> - No Node? It’s fine—static fallbacks are used if present under
/jsor/css
- Learn PHP by reading and writing plain PHP files
- Keep the core small and explicit (no magic)
- Understand HTTP, sessions, and SQL fundamentals
- When you’re ready, graduate to full frameworks like Laravel
MIT