DALT.PHP
Getting started

Quick Start

Your first 5 minutes with DALT.PHP

Quick Start

Get started with DALT.PHP in 5 minutes.

The Learning Cycle

Every challenge follows this pattern:

graph LR
    A[Read Lesson] --> B[Copy Broken Files]
    B --> C[Test the Bug]
    C --> D[Debug & Fix]
    D --> E[Run Verification]
    E --> F{Pass?}
    F -->|No| D
    F -->|Yes| G[Next Challenge]

Your First Challenge

Let's fix your first bug!

1. Read the Lesson

# Open the routing lesson
cat lessons/lesson-02-routing/README.md

Or visit /learn in your browser to read it with nice formatting.

2. Copy Broken Files

# Backup your current routes
cp routes/routes.php routes/routes.php.backup

# Copy the broken routes
cp challenges/broken-routing/routes/routes.php routes/

# Copy the controllers
cp -r challenges/broken-routing/Http/controllers/posts Http/controllers/

3. Test the Bug

Start the server and visit these URLs:

php artisan serve
  • http://localhost:8000/posts - Works fine
  • http://localhost:8000/posts/create - Shows wrong page!
  • http://localhost:8000/posts/1 - Works fine
  • http://localhost:8000/posts/1/edit - 404 error!

Bug Found! Two routes are broken. Can you figure out why?

4. Debug the Code

Open routes/routes.php and look for issues:

// What's wrong with this order?
$router->get('/posts/{id}', 'posts/show.php');
$router->get('/posts/create', 'posts/create.php');

// Why is this commented out?
// $router->get('/posts/{id}/edit', 'posts/edit.php');

Hint: Route order matters! Specific routes should come before generic ones.

5. Fix the Bugs

Fix #1: Move specific route before generic:

// ✅ CORRECT ORDER
$router->get('/posts/create', 'posts/create.php');  // Specific first
$router->get('/posts/{id}', 'posts/show.php');      // Generic after

Fix #2: Uncomment the missing route:

$router->get('/posts/{id}/edit', 'posts/edit.php');

6. Run Verification

php artisan verify broken-routing

Expected 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!

Congratulations! You've completed your first challenge! 🎉

What You Learned

  • How the router matches URLs to routes
  • Why route order matters (specific before generic)
  • How to debug 404 errors
  • How route parameters work ({id})

Next Steps

Now that you understand the basics, continue your journey:

Tips for Success

  1. Read the lesson first - Understand the concept before debugging
  2. Test manually - See the bug in action before fixing
  3. Use dd() - Dump variables to understand what's happening
  4. Read error messages - They often tell you exactly what's wrong
  5. Compare solutions - After fixing, compare with the provided solution

Happy debugging! 🐛🔧

On this page