DALT.PHP
Introduction

Quick Start

Get DALT.PHP running in 5 minutes

Get DALT.PHP up and running in just 5 minutes and complete your first challenge!

Prerequisites

Before you begin, ensure you have:

Check your versions:

php --version    # Should be 8.2 or higher
composer --version
node --version   # Should be 18 or higher
npm --version

Installation

Clone the Repository

git clone https://github.com/Ibnu-Afdel/DALT.PHP.git
cd DALT.PHP

Install Dependencies

# Install PHP dependencies
composer install

# Install platform dependencies (Node/Vite)
npm run install-platform

Platform dependencies are installed in the hidden .dalt/ directory, keeping your workspace clean and focused on PHP learning.

Setup Environment

# Copy environment file
cp .env.example .env

# Run database migrations
php artisan migrate

The default configuration works out of the box with SQLite.

Start Development Servers

You need two terminals running simultaneously:

Terminal 1 - Vite Dev Server:

npm run dev

Terminal 2 - PHP Server:

php artisan serve

Open in Browser

Visit: http://localhost:8000

You should see the DALT.PHP welcome page!

Installation Complete! 🎉

You're now ready to start learning backend development by debugging real code.

Your First Challenge

Let's complete the "Broken Routing" challenge to see how DALT.PHP works. This challenge comes with all the files you need - you'll copy them into your workspace.

Understand the Concept

Visit http://localhost:8000/learn in your browser and click on "Lesson 2: Routing" to learn how routing works.

Take a few minutes to read through the lesson - it explains the concepts you'll be debugging.

Copy the Challenge Files

The challenge includes broken code files that you'll copy into your workspace. In your terminal, run:

# Backup your current routes (just in case)
cp routes/routes.php routes/routes.php.backup

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

# Copy the posts controllers (these come with the challenge)
cp -r course/challenges/broken-routing/Http/controllers/posts app/Http/controllers/

The challenge includes everything you need: broken routes AND the controllers that use them. You're copying a complete (but buggy) feature into your workspace.

See What's Broken

Open your browser and test these URLs:

The URLs don't work as expected. Your job is to figure out why!

Run the Tests

DALT.PHP includes automated tests that check your work. Run:

php artisan verify broken-routing

You'll see helpful output like:

✓ Route get /posts/create exists
✓ Route get /posts/{id}/edit exists
✗ Route order wrong: /posts/create should come before /posts/{id}
  💡 Hint: Move /posts/create BEFORE /posts/{id} in routes/routes.php
✗ File still contains: // $router->get('/posts/{id}/edit'
  💡 Hint: Remove the // comment from the edit route

Results: 2/4 tests passed

The hints tell you exactly what to look for!

Fix the Bugs

Open routes/routes.php in your code editor. You'll see the broken routes. Fix both bugs:

Bug #1 - Wrong Route Order:

The specific route /posts/create comes AFTER the generic route /posts/{id}, so the router matches "create" as an ID. Swap them:

// WRONG ORDER
$router->get('/posts/{id}', 'posts/show.php');
$router->get('/posts/create', 'posts/create.php');  // Never matches!

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

Bug #2 - Commented Route:

The edit route is commented out. Remove the //:

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

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

Save the file!

Verify Your Fix

Run the tests again:

php artisan verify broken-routing

You should see all tests pass:

✓ 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 completed successfully.

Test in Browser

Go back to your browser and verify everything works:

Success! 🎉

Congratulations! 🎉

You've completed your first DALT.PHP challenge! You now understand:

  • Why route order matters (specific before generic)
  • How routers match URL patterns
  • How to debug routing issues

This is how DALT.PHP works - you copy broken code, debug it, fix it, and verify your solution!

What You Learned

In just 5 minutes, you:

  1. ✅ Installed DALT.PHP
  2. ✅ Read a lesson about routing
  3. ✅ Encountered broken code
  4. ✅ Debugged and fixed 2 bugs
  5. ✅ Verified your solution with automated tests
  6. ✅ Understood routing concepts deeply

This is the DALT.PHP learning experience!

Next Steps

Troubleshooting

Port Already in Use

If port 8000 or 5173 is already in use:

# Use different port for PHP
php artisan serve --port=8001

# Kill process on port 5173
lsof -ti:5173 | xargs kill -9

Database Errors

If you get database connection errors:

# Check database file exists
ls -la database/app.sqlite

# Re-run migrations
php artisan migrate:fresh

Vite Assets Not Loading

If Vue components don't work:

  1. Ensure Vite dev server is running (npm run dev)
  2. Check browser console for errors
  3. Try clearing browser cache
  4. Restart both servers

Permission Errors

If you get permission errors:

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

CLI Commands Reference

Quick reference for common commands:

# Development servers
npm run dev              # Start Vite dev server
php artisan serve        # Start PHP server

# Database
php artisan migrate      # Run migrations
php artisan migrate:fresh # Reset and re-run migrations

# Verification
php artisan verify broken-routing    # Verify specific challenge
php artisan verify                   # List all challenges

# Migrations
php artisan make:migration create_posts_table  # Create new migration

Getting Help

If you're stuck:

  1. Check the docs - Most questions are answered here
  2. Read error messages - They often tell you exactly what's wrong
  3. Join Telegram - t.me/daltphp for community help
  4. Open an issue - GitHub Issues

Tips for Success

1. Read Lessons First

Always read the lesson before attempting the challenge. Understanding the concept makes debugging much easier.

2. Use Verification Often

Run php artisan verify frequently. The hints will guide you in the right direction.

3. Read Framework Code

The framework source in framework/Core/ is readable and educational. Don't be afraid to explore it!

4. Take Notes

Document what you learn. Writing reinforces understanding.

5. Don't Rush

Take time to understand why the bug exists and why your fix works. Deep understanding beats speed.


You're all set! Start with Lesson 1: Request Lifecycle or jump straight into Challenge 2: Broken Middleware. Happy debugging! 🐛🔧

On this page