pekral / php-skeleton
Modern PHP package skeleton with strict quality rules, PHPStan max level, Pest testing, and best practices baked in
Fund package maintenance!
Requires
- php: ^8.4
- ergebnis/composer-normalize: ^2.49.0
- laravel/pint: ^1.27.0
- nunomaduro/termwind: ^2
- pekral/cursor-rules: ^0.3
- pekral/phpcs-rules: ^0.4.6
- pekral/rector-rules: ^0.4.7
- pestphp/pest: ^4.3.2
- pestphp/pest-plugin-type-coverage: ^4.0.3
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan: ^2.1.38
- phpstan/phpstan-deprecation-rules: ^2.0.3
- phpstan/phpstan-mockery: ^2.0
- phpstan/phpstan-phpunit: ^2.0.12
- roave/security-advisories: dev-latest
- squizlabs/php_codesniffer: >=4.0.1
- symfony/console: ^8.0.4
This package is auto-updated.
Last update: 2026-03-09 07:50:02 UTC
README
Modern PHP package skeleton with strict quality rules and best practices baked in. Supports PHP 8.4 and 8.5.
Start your next PHP package with confidence. This skeleton comes pre-configured with industry-standard tools for static analysis, testing, and code quality — and includes an interactive installer that configures everything for you.
Features
| Tool | Purpose |
|---|---|
| Pest | Elegant testing framework with 100% coverage requirement |
| PHPStan | Static analysis at maximum level |
| Laravel Pint | Opinionated PHP code style fixer |
| Rector | Automated code refactoring |
| PHP CodeSniffer | Coding standard enforcement |
| Security Advisories | Dependency vulnerability checking |
| Interactive Installer | Automatic project configuration |
Installation
composer create-project pekral/php-skeleton my-package
The interactive installer will guide you through the configuration process.
Interactive Installer
When you run composer create-project, an interactive installer automatically starts and helps you configure your new package.
What the Installer Does
-
Collects Project Information
- Package name (vendor/package format)
- Root PSR-4 namespace (auto-suggested from package name)
- Test namespace (auto-suggested as
{Namespace}Test) - Display name (auto-suggested from package name)
- GitHub repository URL (auto-suggested from package name)
-
Optional: Project Specification
- Paste multi-line project specification text
- Creates
SPEC.mdfile (automatically added to.gitignore) - End input with two empty lines or skip with Enter
-
Performs Automatic Configuration
- Updates
composer.jsonwith your package details - Replaces namespaces across all PHP files
- Clears
README.mdandCHANGELOG.mdfor your content - Updates
LICENSEwith your information - Cleans up
phpstan.neon(removes build-package path) - Cleans up
rector.php(removes build-package path) - Moves all dependencies to
require-dev(except PHP) - Removes skeleton-specific scripts and autoload entries
- Updates
-
Creates Example Files
src/{ClassName}.php— Example class withgreet()methodtests/Unit/{ClassName}Test.php— Pest test for the example class
-
Runs Quality Pipeline
- Installs dependencies with
composer update - Runs
composer fixto apply code style fixes - Runs
composer checkto verify all quality checks pass
- Installs dependencies with
-
Optional Features
- GitHub Actions — Keep or remove CI/CD workflows
- Cursor Rules — Install AI coding assistant rules via
pekral/cursor-rules - Git Repository — Initialize with custom branch name
- Push to Remote — Force push initial commit to GitHub (converts HTTPS to SSH URL)
Installer Flow Example
⚡ PHP Skeleton
Project Configuration
📝 Package Configuration
╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
Package name (vendor/package): acme/my-package
Root namespace [Acme\MyPackage]:
Test namespace [Acme\MyPackageTest]:
Display name [My Package]:
GitHub URL [https://github.com/acme/my-package]:
📋 Review Configuration
╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
GitHub https://github.com/acme/my-package
Name My Package
Namespace Acme\MyPackage
Package acme/my-package
Tests Acme\MyPackageTest
Proceed? [yes]:
⚡ Processing Files
✓ Updated: composer.json
✓ Updated: README.md
✓ Created src/MyPackage.php
✓ Created tests/Unit/MyPackageTest.php
🚀 GitHub Actions
Install GitHub Actions? [yes]:
📋 Cursor Rules
Install cursor rules? [yes]:
📦 Git Repository
Initialize git? [yes]:
Default branch [main]:
✓ Initialized with initial commit
✓ Done!
Your project is ready.
Cancellation & Cleanup
If you press Ctrl+C during installation, the installer will:
- Display a cancellation message
- Automatically delete the partially created project directory
- Exit cleanly
Available Commands
Run All Quality Checks
composer check
This runs the complete quality pipeline:
- Composer normalize
- PHP CodeSniffer
- Laravel Pint
- Rector
- PHPStan
- Security audit
- Tests with 100% coverage
Apply All Fixes
composer fix
Automatically fixes code style and applies refactoring:
- Composer normalize
- Rector refactoring
- Laravel Pint formatting
- PHP CodeSniffer fixes
Individual Commands
| Command | Description |
|---|---|
composer test:coverage |
Run tests with coverage (min 100%) |
composer analyse |
Run PHPStan static analysis |
composer pint-check |
Check code style |
composer pint-fix |
Fix code style |
composer rector-check |
Check for refactoring opportunities |
composer rector-fix |
Apply automated refactoring |
composer phpcs-check |
Check coding standards |
composer phpcs-fix |
Fix coding standard violations |
composer composer-validate |
Validate composer.json schema |
composer composer-normalize-check |
Check composer.json normalization |
composer composer-normalize-fix |
Normalize composer.json |
composer security-audit |
Check for vulnerable dependencies |
Project Structure
After installation, your project will have:
my-package/
├── .github/
│ ├── dependabot.yml # Dependabot (Composer + GitHub Actions)
│ └── workflows/
│ ├── checkers.yml # Quality checks and security scanning
│ ├── release.yml # Release automation
│ ├── stale.yml # Stale issue management
│ └── update-changelog.yml # Changelog automation
├── docs/ # Documentation folder
├── src/
│ └── MyPackage.php # Example class (your namespace)
├── tests/
│ └── Unit/
│ └── MyPackageTest.php # Example Pest test
├── .gitignore # Git ignore rules
├── composer.json # Dependencies and scripts
├── phpstan.neon # PHPStan configuration (level max)
├── phpunit.xml # PHPUnit/Pest configuration
├── pint.json # Laravel Pint rules
├── rector.php # Rector configuration
├── ruleset.xml # PHP CodeSniffer rules
├── CHANGELOG.md # Version history (empty)
├── README.md # Project readme (empty)
└── LICENSE # MIT License
Configuration
PHPStan
Static analysis runs at maximum level with additional rules:
- Deprecation rules
- Mockery extension
# phpstan.neon parameters: level: max treatPhpDocTypesAsCertain: false
Testing
Tests use Pest v4 with strict coverage requirements:
# Runs with 100% minimum coverage using PCOV
composer test:coverage
Code Style
Laravel Pint enforces PSR-12 with additional rules for clean, consistent code.
Rector
Automated refactoring uses rules from pekral/rector-rules package.
GitHub Actions
The skeleton includes comprehensive CI/CD workflows:
| Workflow | Purpose |
|---|---|
checkers.yml |
Quality checks and security scanning on PRs, pushes to master, and weekly schedule |
| Dependabot | Automated dependency updates (Composer + GitHub Actions) |
release.yml |
Release automation |
stale.yml |
Marks and closes stale issues/PRs |
update-changelog.yml |
Automated changelog updates |
All workflows run on PHP 8.4 and 8.5 (matrix).
Requirements
- PHP 8.4 or 8.5 (both versions are supported and tested in CI)
- Composer 2.x
Contributing
Contributions are welcome! Please read our Contributing Guide before submitting a Pull Request.
License
This package is open-sourced software licensed under the MIT license.
Author
Petr Král
- GitHub: @pekral
- Email: kral.petr.88@gmail.com
- X (Twitter): https://x.com/kral_petr_88
Built with care for the PHP community