|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Ploi CLI is a command-line interface for the [Ploi.io](https://ploi.io) server management platform. Built on Laravel Zero (a minimal CLI-focused Laravel framework), it provides 60+ commands for managing servers, sites, databases, SSL, daemons, and more. |
| 8 | + |
| 9 | +## Common Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +# Install dependencies |
| 13 | +composer install |
| 14 | + |
| 15 | +# Run tests (Pest) |
| 16 | +./vendor/bin/pest |
| 17 | + |
| 18 | +# Run a single test file |
| 19 | +./vendor/bin/pest tests/Feature/ExampleTest.php |
| 20 | + |
| 21 | +# Lint code (Laravel Pint) |
| 22 | +./vendor/bin/pint |
| 23 | + |
| 24 | +# Build standalone executable |
| 25 | +php ploi app:build ploi --build-version=<VERSION> |
| 26 | +``` |
| 27 | + |
| 28 | +## Architecture |
| 29 | + |
| 30 | +### Entry Point |
| 31 | +- `/ploi` - Main executable that bootstraps Laravel Zero |
| 32 | +- `/bootstrap/app.php` - Application initialization |
| 33 | + |
| 34 | +### Core Services |
| 35 | +- `app/Services/PloiAPI.php` - HTTP client for Ploi API (all API communication goes through here) |
| 36 | +- `app/Support/Configuration.php` - Manages `.ploi/settings.yml` and `.ploi/provision.yml` project configs |
| 37 | + |
| 38 | +### Command Structure |
| 39 | +All commands extend `app/Commands/Command.php` which provides: |
| 40 | +- `$this->ploi` - PloiAPI instance |
| 41 | +- `$this->configuration` - Configuration instance |
| 42 | +- Output helpers: `info()`, `error()`, `success()`, `warn()` |
| 43 | + |
| 44 | +Commands are organized hierarchically: |
| 45 | +- `app/Commands/` - Top-level commands (init, deploy, provision, token, ssh:login) |
| 46 | +- `app/Commands/Server/` - Server management (create, list, restart, services, etc.) |
| 47 | +- `app/Commands/Site/` - Site management (create, list, repos, SSL, env, etc.) |
| 48 | + |
| 49 | +### Command Concerns (Reusable Traits) |
| 50 | +Located in `app/Commands/Concerns/`: |
| 51 | +- `InteractWithServer` - Server selection and polling logic |
| 52 | +- `InteractWithSite` - Site selection and interaction |
| 53 | +- `InteractWithDatabase` - Database operations |
| 54 | +- `InteractWithUser` - User interaction patterns |
| 55 | + |
| 56 | +### Traits |
| 57 | +Located in `app/Traits/`: |
| 58 | +- `EnsureHasToken` - Validates API token exists |
| 59 | +- `HasPloiConfiguration` - Checks for project config files |
| 60 | +- `HasRepo` - Repository-related operations |
| 61 | + |
| 62 | +### Configuration Files |
| 63 | +- Global token: `~/.ploi/config.php` |
| 64 | +- Project settings: `.ploi/settings.yml` (server ID, site ID, domain) |
| 65 | +- Project provisioning: `.ploi/provision.yml` (commands, services) |
| 66 | + |
| 67 | +## Tech Stack |
| 68 | + |
| 69 | +- **PHP 8.2+** with strict typing |
| 70 | +- **Laravel Zero 11** - CLI framework |
| 71 | +- **Laravel Prompts** - Interactive CLI prompts (select, text, confirm, spin) |
| 72 | +- **Guzzle** - HTTP client (via Illuminate HTTP facade) |
| 73 | +- **Pest** - Testing framework |
| 74 | +- **Laravel Pint** - Code formatter |
| 75 | +- **Box** - PHAR builder for standalone executable |
| 76 | + |
| 77 | +## Build Process |
| 78 | + |
| 79 | +Builds are automated via GitHub Actions (`.github/workflows/build.yml`). On push to `main`: |
| 80 | +1. Auto-increments version from latest git tag |
| 81 | +2. Runs `php ploi app:build ploi --build-version=X.Y` |
| 82 | +3. Commits built binary to `builds/ploi` |
| 83 | +4. Creates new git tag |
0 commit comments