No description
Find a file
2025-11-17 22:55:59 +11:00
src Refactor: Use command registration instead of separate binary 2025-11-11 22:37:26 +11:00
tests test: add missing tests 2025-11-17 22:55:59 +11:00
.gitignore Initial commit: Core-dev with admin tools for track creators 2025-11-11 22:11:17 +11:00
composer.json Refactor: Use command registration instead of separate binary 2025-11-11 22:37:26 +11:00
LICENSE Initial commit: Core-dev with admin tools for track creators 2025-11-11 22:11:17 +11:00
README.md Refactor: Use command registration instead of separate binary 2025-11-11 22:37:26 +11:00

Phpling Core Dev

Development tools for Phpling track creators. Adds admin commands for managing exercises.

What is this?

phpling/core-dev extends phpling/core with additional commands for track creators:

  • add - Add new exercises and automatically shift existing ones
  • move - Move exercises and automatically renumber them

These commands are not meant for learners - they're for people creating and managing exercise tracks.

Installation

Install as a dev dependency when creating or working on a track:

composer require --dev phpling/core-dev

When installed, the phpling binary automatically detects core-dev and enables admin commands!

Usage

Standard Commands (Always Available)

./vendor/bin/phpling run      # Run next exercise
./vendor/bin/phpling watch    # Watch mode
./vendor/bin/phpling check 1  # Check specific exercise
./vendor/bin/phpling progress # Show progress
./vendor/bin/phpling reset    # Reset progress

Admin Commands (When core-dev is installed)

Add a New Exercise

./vendor/bin/phpling add <number> "<title>"

Example:

./vendor/bin/phpling add 5 "Type Casting"

This will:

  • Create a new exercise at position 5
  • Automatically shift existing exercises (5 becomes 6, etc.)
  • Generate template files for both the exercise and test
  • Create files:
    • exercises/005_type_casting.php
    • tests/exercises/Exercise005Test.php

Move an Exercise

./vendor/bin/phpling move <from> <to>

Example:

./vendor/bin/phpling move 20 5

This will:

  • Move exercise from position 20 to position 5
  • Automatically renumber all affected exercises
  • Update all file references and imports

Workflow for Track Creators

Initial Setup

# Create your track
mkdir my-awesome-track
cd my-awesome-track
composer init

# Install dependencies
composer require phpling/core
composer require --dev phpling/core-dev

# Create structure
mkdir -p exercises tests/exercises src

Creating Exercises

# Add your first exercise
./vendor/bin/phpling add 1 "Hello World"

# Edit the generated files
vim exercises/001_hello_world.php
vim tests/exercises/Exercise001Test.php

# Test it
./vendor/bin/phpling check 1

# Add more exercises
./vendor/bin/phpling add 2 "Variables"
./vendor/bin/phpling add 3 "Functions"

Reorganizing Exercises

# Oops, I want to move "Variables" before "Hello World"
./vendor/bin/phpling move 2 1

# Now the order is:
# 001_variables.php (was 002)
# 002_hello_world.php (was 001)
# 003_functions.php (unchanged)

Inserting Exercises

# Insert a new exercise between 1 and 2
./vendor/bin/phpling add 2 "Data Types"

# Now the order is:
# 001_variables.php
# 002_data_types.php (new!)
# 003_hello_world.php (was 002)
# 004_functions.php (was 003)

Why Separate from Core?

Keeps learner experience clean:

  • Learners don't see confusing admin commands in help
  • Smaller binary size for production use
  • Clear separation of concerns

Dev dependency model:

  • Only installed when developing a track
  • Not included in learner's project
  • Follows standard composer patterns

How It Works

When you install phpling/core-dev as a dev dependency, the phpling binary (from phpling/core) automatically detects its presence and switches to using DevApplication instead of the base Application.

This means:

  • Without core-dev: phpling only has learner commands
  • With core-dev: phpling has learner + admin commands

Architecture

core-dev/
├── src/
│   ├── DevApplication.php              # Extends Application, registers admin commands
│   ├── Commands/
│   │   ├── AddExerciseCommand.php     # Add new exercises
│   │   └── MoveExerciseCommand.php    # Move/renumber exercises
│   └── Core/
│       └── ExerciseManager.php         # Exercise manipulation utilities
├── composer.json                       # Requires phpling/core
└── README.md                           # Usage guide

core-dev/ ├── src/ │ ├── DevApplication.php # Extends Application with admin commands │ ├── Commands/ │ │ ├── AddExerciseCommand.php # Add exercise logic │ │ └── MoveExerciseCommand.php # Move exercise logic │ └── Core/ │ └── ExerciseManager.php # Exercise manipulation utilities ├── phpling-dev # CLI binary with admin commands └── composer.json # Requires phpling/core


## For Track Development

Set up composer scripts for convenience:

```json
{
    "scripts": {
        "check": "./vendor/bin/phpling check",
        "run": "./vendor/bin/phpling run",
        "add": "./vendor/bin/phpling add",
        "move": "./vendor/bin/phpling move"
    }
}

Then:

composer run add -- 10 "New Exercise"
composer run move -- 10 5

Requirements

  • PHP 8.4 or higher
  • phpling/core ^1.0

License

MIT