Download the PHP package nexus4812/php-class-gen without Composer
On this page you can find all versions of the php package nexus4812/php-class-gen. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nexus4812/php-class-gen
More information about nexus4812/php-class-gen
Files in nexus4812/php-class-gen
Package php-class-gen
Short Description PHP code generator for repositories, entities, and tests with DSL support
License MIT
Informations about the package php-class-gen
This project is currently in draft stage
Breaking changes may occur until the official release.
PHP Class Generator
English
A powerful and flexible PHP code generation library. Create custom code generators easily with a command-based architecture. Perfect for generating boilerplate code, CQRS patterns, domain objects, and more.
Features
nette/php-generator Extensions
-
Built on nette/php-generator with additional convenient features for basic code generation:
- Automatic Use Statement Generation: Automatically adds import statements for used classes
- Auto Strict Types: Automatically inserts
declare(strict_types=1); - PSR-4 Auto Mapping: Reads composer.json configuration to automatically map namespaces to file paths
- Automatic Dependency Resolution: Analyzes class dependencies and auto-generates required use statements
- Command-Based Architecture: Easily create and manage reusable code generation commands
CLI is built on symfony/console.
MCP (Model Context Protocol) Support
Integrates with Claude Code/Claude Desktop for AI-assisted code generation:
- Automatically exposes Symfony commands as MCP tools
- Execute code generation commands directly from prompts
- Project-specific code generation available from AI assistants
Installation
Quick Start
1. Create Configuration File
Create phpgen.php in your project root:
2. Generate Code Using CLI
3. Verify Installation
Setup
Setup Steps
- Create Configuration File (
phpgen.php) - Configure PSR-4 Mapping (can be auto-loaded from composer.json)
- Register Commands
<� Built-in Commands
The following commands are available:
- query:generate - Laravel CQRS Query pattern
- command:generate - Laravel CQRS Command pattern
- dto:create - DTO classes
- class:create - Simple classes
See src/Console/Commands/ for details.
Usage Examples
Creating Custom Commands
Basic Pattern
Registering Commands
See src/Console/Commands/Example/Laravel/ for detailed implementation examples.
Configuration
PSR-4 Mapping Management
Handle complex namespace scenarios with priority mappings:
Mapping Rules:
- Priority mappings override regular mappings
- Duplicates within the same priority level cause errors
- Duplicates between different priority levels are allowed (priority wins)
Configuration Methods
MCP Server Integration
PhpGen works as an MCP (Model Context Protocol) server and can be used directly from Claude Code or Claude Desktop.
Architecture
Built on the php-mcp/server library, automatically exposing existing Symfony commands as MCP tools.
Starting the Server
Claude Desktop Configuration
Add to Claude Desktop configuration file (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):
Available MCP Tools
Commands configured in your configuration file are available to AI via MCP.
Note: All tools are automatically generated from Symfony commands registered in phpgen.php.
Usage Example with Claude Code
=� Architecture
Core Generation Flow
- Command: Processes command-line input and defines files to generate
- Project: Collects multiple FileBlueprints
- FileBlueprint: Defines class/interface/enum structure
- Generator: Generates code using Nette PHP Generator
- CodeWriter: Writes files to disk
See the src/ directory for details.
Troubleshooting
Debug Mode
Common Errors
"No PSR-4 mappings configured"
"Duplicate directory"
All versions of php-class-gen with dependencies
nette/php-generator Version ^4.0
php-mcp/server Version ^3.0
symfony/console Version ^6.0|^7.0