CLI Commands
Complete reference for DALT.PHP Artisan CLI commands
DALT.PHP includes a powerful command-line interface (CLI) called Artisan for common development tasks.
Getting Help
View all available commands:
php artisan helpDevelopment Commands
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 8000If the specified port is in use, Artisan automatically finds the next available port.
What it does:
- Starts PHP's built-in web server
- Serves files from the
public/directory - Uses
public/router.phpfor routing - Hot-reloads on file changes
dev
Start both PHP and Vite development servers simultaneously.
php artisan devWhat it does:
- Starts PHP server on port 8000
- Starts Vite dev server on port 5173
- Enables hot module replacement (HMR) for frontend
- Runs both servers in parallel
Requires Node.js and npm installed. Run npm install in .dalt/ directory first.
Press Ctrl+C to stop both servers.
Database Commands
migrate
Run all pending database migrations.
php artisan migrateWhat it does:
- Scans
database/migrations/directory - Executes
.sqlfiles in chronological order - Tracks executed migrations in
migrationstable - Skips already-run migrations
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:freshWARNING: This deletes ALL data! Only use in development.
What it does:
- Deletes the SQLite database file
- Recreates the database
- Runs all migrations
- Resets migration tracking
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_postsGenerated file:
database/migrations/20240315120000_create_posts_table.sqlTemplate 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 KEYNext steps:
- Edit the generated file
- Customize table structure
- Run
php artisan migrate
Testing Commands
test
Run the Pest test suite.
php artisan testWhat it does:
- Executes all tests in
tests/directory - Uses Pest PHP testing framework
- Shows test results with colors
- Reports coverage (if 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.12sverify
Verify a challenge solution.
php artisan verify <challenge-name>Available challenges:
broken-routingbroken-middlewarebroken-authbroken-databasebroken-session
Example:
php artisan verify broken-routingOutput:
╔══════════════════════════════════════════════════════════════╗
║ 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 it does:
- Runs automated tests for the challenge
- Checks for specific bugs and fixes
- Provides hints if tests fail
- Logs results to
storage/logs/challenges.log
Exit codes:
0- All tests passed1- Some tests failed
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 authWhat it does:
- Copies controller files to
Http/controllers/ - Copies view files to
resources/views/ - Appends routes to
routes/routes.php - Creates installation marker
Installed files:
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.phpAdded 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
| Command | Purpose | Example |
|---|---|---|
serve | Start dev server | php artisan serve |
dev | Start PHP + Vite | php artisan dev |
migrate | Run migrations | php artisan migrate |
migrate:fresh | Reset database | php artisan migrate:fresh |
make:migration | Create migration | php artisan make:migration create_posts |
test | Run tests | php artisan test |
verify | Check challenge | php artisan verify broken-routing |
example:install | Install example | php artisan example:install auth |
help | Show help | php artisan help |
Common Workflows
Starting Development
# Terminal 1: Start servers
php artisan dev
# Terminal 2: Watch logs (optional)
tail -f storage/logs/app.logDatabase Setup
# Create migration
php artisan make:migration create_posts_table
# Edit: database/migrations/TIMESTAMP_create_posts_table.sql
# Run migration
php artisan migrateWorking on Challenges
# Copy challenge files
cp course/challenges/broken-routing/routes/routes.php routes/
# Fix the bugs...
# Verify solution
php artisan verify broken-routingFresh Start
# Reset database
php artisan migrate:fresh
# Clear logs
rm storage/logs/*.log
# Restart server
php artisan serveTroubleshooting
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 -9Migration Errors
If migrations fail:
# Check migration syntax
cat database/migrations/TIMESTAMP_file.sql
# Reset and try again
php artisan migrate:freshVite Not Starting
If php artisan dev fails:
# Install dependencies
cd .dalt
npm install
# Try again
cd ..
php artisan devPermission Errors
If you see permission denied:
# Make artisan executable
chmod +x artisan
# Fix storage permissions
chmod -R 775 storage
chmod -R 775 databaseAdvanced 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 serveRunning Specific Tests
# Run specific test file
vendor/bin/pest tests/Feature/RoutingTest.php
# Run with coverage
vendor/bin/pest --coverageMigration 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 serveNext Steps
- Configuration - Configure your application
- Verification System - How challenge verification works
- Building a Blog - Use these commands in practice