Contributing
How to contribute to DALT.PHP
Thank you for your interest in contributing to DALT.PHP! This guide will help you get started.
Ways to Contribute
1. Report Bugs
Found a bug? Help us fix it!
Before reporting:
- Check existing issues on GitHub
- Verify it's reproducible
- Test on latest version
What to include:
- Clear description
- Steps to reproduce
- Expected vs actual behavior
- Environment (OS, PHP version)
- Error messages or screenshots
Example:
**Bug**: Verification fails for broken-routing challenge
**Steps**:
1. Copy challenge files
2. Fix both bugs
3. Run `php artisan verify broken-routing`
**Expected**: All tests pass
**Actual**: Test 3 fails with "route not found"
**Environment**: Ubuntu 22.04, PHP 8.22. Suggest Features
Have an idea? We'd love to hear it!
Good feature requests include:
- Clear use case
- Why it's valuable
- How it fits DALT.PHP's mission
- Potential implementation approach
Example:
**Feature**: Add "Broken API" challenge
**Use case**: Teach REST API debugging
**Value**: APIs are fundamental to modern backends
**Fits mission**: Hands-on debugging practice
**Implementation**: Challenge with JSON response bugs3. Improve Documentation
Documentation is always welcome!
Areas to improve:
- Fix typos or unclear explanations
- Add missing examples
- Improve code comments
- Translate to other languages
- Add diagrams or visuals
4. Create Challenges
Add new debugging challenges!
Requirements:
- Educational value
- Realistic bugs
- Clear learning objectives
- Automated tests
- Comprehensive README
See Creating Challenges below.
5. Enhance Framework
Improve the core framework!
Areas:
- Performance optimization
- New features
- Bug fixes
- Code quality
- Test coverage
Getting Started
Development Setup
Fork and Clone
# Fork on GitHub, then clone your fork
git clone https://github.com/YOUR_USERNAME/DALT.PHP.git
cd DALT.PHPInstall Dependencies
# PHP dependencies
composer install
# Frontend dependencies
cd .dalt
npm install
cd ..Setup Environment
# Copy environment file
cp .env.example .env
# Run migrations
php artisan migrateStart Development
# Terminal 1: Frontend
cd .dalt && npm run dev
# Terminal 2: Backend
php artisan serveVerify Setup
Visit http://localhost:8000 and check:
- Homepage loads
/learnshows lessons- Verification works
Development Workflow
- Create branch -
git checkout -b feature/your-feature - Make changes - Edit code, add tests
- Test locally - Verify everything works
- Commit - Clear, descriptive messages
- Push -
git push origin feature/your-feature - Pull request - Submit on GitHub
Code Standards
PHP Code Style
Follow PSR-12 coding standards:
<?php
namespace Core;
class ExampleClass
{
private string $property;
public function exampleMethod(string $param): string
{
if ($condition) {
return $result;
}
return $default;
}
}Key points:
- 4 spaces indentation
- Opening braces on same line for methods
- Type hints for parameters and returns
- Descriptive variable names
- Comments for complex logic
JavaScript/Vue Style
// Use const/let, not var
const items = [];
// Arrow functions for callbacks
items.map(item => item.id);
// Descriptive names
function calculateTotal(items) {
return items.reduce((sum, item) => sum + item.price, 0);
}Commit Messages
Format: type: description
Types:
feat- New featurefix- Bug fixdocs- Documentationstyle- Formattingrefactor- Code restructuringtest- Testschore- Maintenance
Examples:
feat: add broken-api challenge
fix: verification fails on Windows
docs: improve routing lesson clarity
refactor: simplify Database class
test: add tests for Router classCreating Challenges
Challenge Structure
course/challenges/your-challenge/
├── README.md # Challenge description
├── tests.php # Verification tests
├── routes/
│ └── routes.php # Broken routes
├── Http/controllers/
│ └── ... # Broken controllers
└── framework/Core/
└── ... # Broken framework filesStep-by-Step Guide
Plan the Challenge
Define:
- Learning objective - What concept to teach
- Bug type - What's broken
- Difficulty - Beginner/Medium/Advanced
- Prerequisites - Required knowledge
Create Directory
mkdir -p course/challenges/your-challenge
cd course/challenges/your-challengeWrite README
Create README.md:
# Challenge: Your Challenge Name
## Difficulty: Medium
## Learning Objectives
- Understand X concept
- Debug Y issue
- Apply Z best practice
## The Bug
Description of what's broken...
## Setup Instructions
1. Copy files...
2. Test the bug...
## Hints
- Check file X
- Look for pattern YCreate Broken Files
Copy working files and introduce bugs:
# Copy from framework
cp ../../framework/Core/Router.php framework/Core/
# Edit to add bugs
nano framework/Core/Router.phpWrite Tests
Create tests.php:
<?php
return [
'test_name' => [
'type' => 'file_contains',
'file' => 'path/to/file.php',
'search' => 'expected_code',
'hint' => 'Helpful hint'
],
// More tests...
];Test Verification
# Test broken state (should fail)
php artisan verify your-challenge
# Fix bugs
# ...
# Test fixed state (should pass)
php artisan verify your-challengeChallenge Best Practices
1. Realistic Bugs
Use bugs developers actually encounter:
// Good: Common mistake
if ($password == $hash) // Should use password_verify()
// Bad: Artificial
if (true === false) // No one writes this2. Clear Learning Path
One concept per challenge:
- Broken Routing → Route order
- Broken Auth → Password hashing
- Broken Database → SQL injection
3. Progressive Difficulty
Start simple, increase complexity:
- Beginner: 1-2 bugs, obvious fixes
- Medium: 2-3 bugs, requires understanding
- Advanced: 3+ bugs, subtle issues
4. Helpful Hints
Guide without giving away:
// Too vague
'hint' => 'Fix the code'
// Too specific
'hint' => 'Change line 42 to: password_verify($pass, $hash)'
// Just right
'hint' => 'Use password_verify() instead of == comparison'5. Comprehensive Tests
Test all aspects:
return [
'bug_fixed' => [...], // Main bug
'no_regression' => [...], // Didn't break other things
'best_practice' => [...], // Used correct approach
'edge_cases' => [...] // Handles edge cases
];Improving Lessons
Lesson Structure
course/lessons/XX-topic/
├── README.md # Lesson content
└── examples/ # Code examples (optional)Writing Guidelines
1. Clear Explanations
## How Routing Works
The router matches URLs to controllers:
1. Request comes in: `/posts/123`
2. Router checks patterns: `/posts/{id}`
3. Extracts parameter: `id = 123`
4. Loads controller: `posts/show.php`2. Code Examples
Show before/after:
// ❌ Wrong
$router->get('/posts/{id}', 'show.php');
$router->get('/posts/create', 'create.php'); // Never matches!
// ✅ Correct
$router->get('/posts/create', 'create.php'); // Specific first
$router->get('/posts/{id}', 'show.php'); // Generic after3. Visual Aids
Use diagrams when helpful:
Request → Router → Middleware → Controller → View → Response4. Practice Exercises
End with hands-on tasks:
## Practice
1. Add a route for `/about`
2. Create the controller
3. Test in browserTesting
Running Tests
# Run all tests
php artisan test
# Run specific test
vendor/bin/pest tests/Feature/RouterTest.php
# With coverage
vendor/bin/pest --coverageWriting Tests
Create tests for new features:
<?php
use function Pest\Laravel\{get, post};
it('routes to correct controller', function () {
$router = new Core\Router();
$router->get('/test', 'test.php');
expect($router->routes['GET'])->toHaveKey('/test');
});
it('extracts route parameters', function () {
$router = new Core\Router();
$router->get('/posts/{id}', 'show.php');
// Test parameter extraction
$_SERVER['REQUEST_URI'] = '/posts/123';
$_SERVER['REQUEST_METHOD'] = 'GET';
$router->route('/posts/123', 'GET');
expect($_GET['id'])->toBe('123');
});Test Coverage
Aim for high coverage:
- Core classes: 80%+
- Controllers: 60%+
- Helpers: 90%+
Documentation
Writing Documentation
Structure:
- Overview
- Examples
- Details
- Troubleshooting
- Related topics
Style:
- Clear and concise
- Code examples
- Real-world use cases
- Beginner-friendly
Example:
## Configuration
DALT.PHP uses `.env` for configuration.
### Setup
Copy the example file:
\`\`\`bash
cp .env.example .env
\`\`\`
### Database
Configure your database:
\`\`\`bash
DB_DRIVER=sqlite
DB_DATABASE=database/app.sqlite
\`\`\`
See [Configuration Guide](/docs/reference/configuration) for all options.Documentation Standards
- Use MDX format
- Include imports for components
- Add code syntax highlighting
- Provide working examples
- Link to related docs
Pull Request Process
Before Submitting
Checklist:
- Code follows style guidelines
- Tests pass locally
- New tests added for new features
- Documentation updated
- Commit messages are clear
- No merge conflicts
Submitting PR
Push Your Branch
git push origin feature/your-featureAddress Feedback
Make requested changes:
# Make changes
git add .
git commit -m "fix: address review feedback"
git push origin feature/your-featureMerge
Once approved, maintainers will merge your PR!
PR Template
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Documentation
- [ ] Refactoring
## Testing
How to test these changes
## Checklist
- [ ] Tests pass
- [ ] Documentation updated
- [ ] No breaking changesCode Review Guidelines
For Contributors
Responding to feedback:
- Be open to suggestions
- Ask questions if unclear
- Explain your reasoning
- Make requested changes promptly
Example response:
> Consider using password_verify() here
Good catch! I've updated it to use password_verify()
for timing-safe comparison. Updated in commit abc123.For Reviewers
What to check:
- Code quality and style
- Test coverage
- Documentation
- Performance impact
- Security implications
Providing feedback:
- Be constructive and kind
- Explain the "why"
- Suggest alternatives
- Acknowledge good work
Example feedback:
Great work on this feature! A few suggestions:
1. Consider extracting this logic into a separate method
for better testability
2. Add a test case for the edge case where $user is null
3. Update the README to mention this new feature
Otherwise looks good! 👍Community Guidelines
Code of Conduct
Be respectful:
- Treat everyone with respect
- Welcome newcomers
- Be patient with questions
- Give constructive feedback
Be collaborative:
- Share knowledge
- Help others learn
- Credit contributors
- Celebrate successes
Be professional:
- Stay on topic
- Avoid personal attacks
- Respect different opinions
- Focus on the code, not the person
Getting Help
Stuck? Ask for help!
- GitHub Discussions - General questions
- GitHub Issues - Bug reports
- Telegram - Quick questions
- Documentation - Reference material
When asking:
- Describe what you tried
- Include error messages
- Share relevant code
- Specify your environment
Project Structure
Understanding the codebase:
DALT.PHP/
├── .dalt/ # Platform internals
│ ├── Http/controllers/ # Learning UI
│ ├── resources/ # Platform assets
│ └── routes/ # Platform routes
├── app/Http/controllers/ # User controllers
├── course/ # Learning content
│ ├── lessons/ # Lesson markdown
│ └── challenges/ # Challenge folders
├── config/ # Configuration
├── database/ # Migrations & SQLite
├── framework/Core/ # Framework classes
│ ├── Router.php
│ ├── Database.php
│ ├── Session.php
│ ├── Middleware/
│ └── ChallengeVerifier.php
├── public/ # Web root
│ ├── index.php # Entry point
│ └── router.php # Dev server router
├── routes/ # User routes
├── storage/ # Logs & cache
└── tests/ # Test suiteKey Files
Entry Points:
public/index.php- Application bootstrapartisan- CLI entry point
Core Classes:
framework/Core/Router.php- Routing systemframework/Core/Database.php- Database wrapperframework/Core/Session.php- Session managementframework/Core/ChallengeVerifier.php- Verification system
Configuration:
config/app.php- App settingsconfig/database.php- Database config.env- Environment variables
Common Tasks
Adding a New Route
// In routes/routes.php
$router->get('/new-route', 'new-controller.php');Creating a Controller
<?php
// In Http/controllers/new-controller.php
$data = ['message' => 'Hello World'];
view('new-view', $data);Adding a Migration
# Create migration
php artisan make:migration create_table_name
# Edit: database/migrations/TIMESTAMP_create_table_name.sql
# Run migration
php artisan migrateAdding a Test
<?php
// In tests/Feature/NewFeatureTest.php
it('does something', function () {
// Test code
expect(true)->toBeTrue();
});Troubleshooting
Common Issues
Port already in use:
# Kill process on port 8000
lsof -ti:8000 | xargs kill -9
# Or use different port
php artisan serve 127.0.0.1 8080Composer dependencies:
# Clear cache
composer clear-cache
# Reinstall
rm -rf vendor
composer installDatabase issues:
# Reset database
php artisan migrate:fresh
# Check permissions
chmod 664 database/app.sqlite
chmod 775 database/Frontend not building:
cd .dalt
rm -rf node_modules
npm install
npm run devRelease Process
For maintainers releasing new versions:
Update Changelog
Document changes in CHANGELOG.md:
## [1.1.0] - 2024-03-15
### Added
- New broken-api challenge
- PostgreSQL support
### Fixed
- Verification on Windows
- Route parameter extraction
### Changed
- Improved error messagesCreate Tag
git tag -a v1.1.0 -m "Release v1.1.0"
git push origin v1.1.0GitHub Release
Create release on GitHub with:
- Version number
- Changelog
- Download links
- Migration notes
Recognition
Contributors
All contributors are recognized in:
- GitHub contributors page
- README.md
- Release notes
Hall of Fame
Outstanding contributions earn:
- Mention in documentation
- Special badge
- Eternal gratitude! 🎉
Resources
Documentation
- Architecture - System design
- CLI Commands - Command reference
- Verification System - Testing guide
External Resources
- PSR-12 - PHP coding standard
- Conventional Commits - Commit format
- Semantic Versioning - Version numbering
Community
Thank You!
Your contributions make DALT.PHP better for everyone. Whether you're fixing a typo, adding a feature, or creating a challenge, every contribution matters.
Happy coding! 🚀
Questions? Open a GitHub Discussion or join our Telegram community!