DALT.PHP
Reference

CLI Commands

Framework and guided-learning command reference

DALT.PHP Artisan has two command groups:

  • Core commands: always available
  • Guided-learning commands: available only when .dalt is installed

Use this to check mode:

php artisan platform:status

Getting Help

View all available commands:

php artisan help

Core Commands

These work in both core and guided-learning experiences.

Development

serve

Start the PHP development server.

php artisan serve [host] [port]

Default: 127.0.0.1:8000

Examples:

# Start on default port 8000
php artisan serve

# Start on custom port
php artisan serve 127.0.0.1 8080

# Make accessible from network
php artisan serve 0.0.0.0 8000

If the specified port is in use, Artisan automatically finds the next available port.

What it does: This command starts PHP's built-in web server and immediately begins serving files from the public/ directory explicitly routing requests through public/router.php. It also enables hot-reloading for rapid development, freeing you from manual restarts.

dev (guided learning)

Start both PHP and Vite development servers simultaneously.

php artisan dev

What it does: When running in guided learning mode, this command seamlessly starts both the PHP server on port 8000 and the Vite development server on port 5173. By running these servers in parallel, it automatically enables hot module replacement (HMR) for your entire frontend.

Guided-learning command. Requires .dalt and Node.js dependencies.

Press Ctrl+C to stop both servers.

Database Commands

migrate

Run all pending database migrations.

php artisan migrate

What it does: Running this command scans your database/migrations/ directory and executes any .sql files chronologically. The framework strictly tracks executed migrations inside a migrations table, guaranteeing that past migrations are safely skipped.

Output example:

Running migration: 20240315120000_create_users_table.sql
✓ Success

Running migration: 20240315130000_create_posts_table.sql
✓ Success

Ran 2 migrations.

Migrations are idempotent - safe to run multiple times.

migrate:fresh

Drop the database and run all migrations from scratch.

php artisan migrate:fresh

WARNING: This deletes ALL data! Only use in development.

What it does: This command completely deletes your current SQLite database file and reconstructs the database from scratch. All tables and migration tracking are reset, allowing all structural migrations to sequentially execute cleanly.

Use cases:

  • Starting fresh during development
  • Resetting test data
  • Fixing migration conflicts

make:migration

Create a new SQL migration file.

php artisan make:migration <name>

Examples:

# Create posts table migration
php artisan make:migration create_posts_table

# Create users table migration
php artisan make:migration create_users_table

# Add column migration
php artisan make:migration add_status_to_posts

Generated file:

database/migrations/20240315120000_create_posts_table.sql

Template content:

-- Migration: create_posts_table
-- Created: 2024-03-15 12:00:00

CREATE TABLE IF NOT EXISTS posts (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name VARCHAR(255) NOT NULL,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

-- Add indexes here
-- CREATE INDEX IF NOT EXISTS idx_posts_name ON posts(name);

-- Notes:
-- SQLite: INTEGER PRIMARY KEY AUTOINCREMENT
-- MySQL:  INT AUTO_INCREMENT PRIMARY KEY
-- PostgreSQL: SERIAL PRIMARY KEY

Next steps:

  1. Edit the generated file
  2. Customize table structure
  3. Run php artisan migrate

Testing

test

Run the Pest test suite.

php artisan test

What it does: Running this command launches the integrated Pest PHP testing framework across your tests/ directory. Results are color-coded in your terminal, and coverage guarantees are visually reported if properly configured.

Requires Pest installed: composer require pestphp/pest --dev

Output example:

PASS  Tests\Feature\RoutingTest
✓ homepage loads successfully
✓ posts index shows all posts
✓ single post shows correct data

Tests:  3 passed
Time:   0.12s

Guided-Learning Commands

These commands are available only when .dalt exists.

challenge:list

List all available challenges with difficulty and pass status.

php artisan challenge:list

challenge:start

Load broken files for a challenge into your app (with confirmation).

php artisan challenge:start <challenge-name>

Available challenges:

  • broken-routing
  • broken-middleware
  • broken-auth
  • broken-database
  • broken-session

Example:

php artisan challenge:start broken-routing

challenge:verify

Verify your fix against the active challenge (checks the real app).

php artisan challenge:verify

Run php artisan challenge:start &lt;name&gt; first to load a challenge, then challenge:verify to check your fix.

challenge:reset

Reset to the buggy baseline for a fresh start on the active challenge.

php artisan challenge:reset

challenge:stop

Stop the active challenge and restore your clean app.

php artisan challenge:stop

Output:

╔══════════════════════════════════════════════════════════════╗
║           DALT Challenge Verification System                ║
╚══════════════════════════════════════════════════════════════╝

Verifying: broken-routing
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✓ Route get /posts/create exists
✓ Route get /posts/{id}/edit exists
✓ Route order correct: specific before generic
✓ No problematic code found

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Results: 4/4 tests passed
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✅ All tests passed! Challenge complete!

What challenge:verify does:

  • Runs automated tests for the active challenge
  • Checks for specific bugs and fixes
  • Provides hints if tests fail
  • Logs results to storage/logs/challenges.log

Exit codes:

  • 0 - All tests passed
  • 1 - Some tests failed

platform:status

Show current mode (guided learning installed or core-only).

php artisan platform:status

platform:clean

Remove the guided learning layer (.dalt) and keep the framework core.

php artisan platform:clean

platform:remove remains as a compatibility alias.

Example Commands

example:install

Install pre-built example code.

php artisan example:install <example-name>

Available examples:

  • auth - Complete authentication system

Example:

php artisan example:install auth

What it does: This strictly copies pre-built controller files into your app/Http/controllers/ folder and associated view files into the resources/views/ folder. It will then automatically append the corresponding routing logic directly into your app's routes.php file and safely mark the installation complete.

Installed files:

app/Http/controllers/
├── session/
│   ├── create.php (login form)
│   ├── store.php (login handler)
│   └── destroy.php (logout)
└── registration/
    ├── create.php (register form)
    └── store.php (register handler)

resources/views/auth/
├── login.view.php
└── register.view.php

Added routes:

$router->get('/register', 'registration/create.php')->only('guest');
$router->post('/register', 'registration/store.php')->only(['guest','csrf']);
$router->get('/login', 'session/create.php')->only('guest');
$router->post('/session', 'session/store.php')->only(['guest','csrf']);
$router->delete('/session', 'session/destroy.php')->only(['auth','csrf']);

After installation, visit /register or /login to use the auth system.

Command Reference

Quick Reference Table

CommandPurposeExample
serveStart dev serverphp artisan serve
devStart PHP + Vitephp artisan dev
migrateRun migrationsphp artisan migrate
migrate:freshReset databasephp artisan migrate:fresh
make:migrationCreate migrationphp artisan make:migration create_posts
testRun testsphp artisan test
challenge:listList challengesphp artisan challenge:list
challenge:startLoad challengephp artisan challenge:start broken-routing
challenge:verifyVerify fixphp artisan challenge:verify
challenge:resetReset to buggyphp artisan challenge:reset
challenge:stopStop challengephp artisan challenge:stop
platform:statusShow current modephp artisan platform:status
platform:cleanRemove guided learningphp artisan platform:clean
example:installInstall examplephp artisan example:install auth
helpShow helpphp artisan help

Common Workflows

Starting Development

# Terminal 1: Start servers
php artisan serve

# Terminal 2 (optional): start frontend HMR when using guided learning
php artisan dev

Database Setup

# Create migration
php artisan make:migration create_posts_table

# Edit: database/migrations/TIMESTAMP_create_posts_table.sql

# Run migration
php artisan migrate

Working on Challenges

# Start a challenge (loads broken files)
php artisan challenge:start broken-routing

# Fix the bugs...

# Verify solution
php artisan challenge:verify

Fresh Start

# Reset database
php artisan migrate:fresh

# Clear logs
rm storage/logs/*.log

# Restart server
php artisan serve

Troubleshooting

Port Already in Use

If you see "Address already in use":

# Use different port
php artisan serve 127.0.0.1 8080

# Or kill existing process
lsof -ti:8000 | xargs kill -9

Migration Errors

If migrations fail:

# Check migration syntax
cat database/migrations/TIMESTAMP_file.sql

# Reset and try again
php artisan migrate:fresh

Vite Not Starting

If php artisan dev fails:

# Confirm guided-learning mode
php artisan platform:status

# Reinstall dependencies from project root
npm install

# Try again
php artisan dev

Permission Errors

If you see permission denied:

# Make artisan executable
chmod +x artisan

# Fix storage permissions
chmod -R 775 storage
chmod -R 775 database

Advanced Usage

Custom Server Configuration

# Bind to all interfaces
php artisan serve 0.0.0.0 8000

# Use specific PHP version
/usr/bin/php8.2 artisan serve

Running Specific Tests

# Run specific test file
vendor/bin/pest tests/Feature/RoutingTest.php

# Run with coverage
vendor/bin/pest --coverage

Migration Management

# Check migration status
sqlite3 database/app.sqlite "SELECT * FROM migrations;"

# Manually mark migration as run
sqlite3 database/app.sqlite "INSERT INTO migrations (migration) VALUES ('20240315_file.sql');"

Environment Variables

Some commands respect environment variables:

# Use different database
DB_DATABASE=database/test.sqlite php artisan migrate

# Enable debug mode
APP_DEBUG=true php artisan serve

Next Steps

On this page