shahmal1yev / blugen
Code generator based on ATProto lexicons.
Requires
- php: ^8.1
- kongulov/interact-with-enum: ^1.0
- nette/php-generator: ^4.1.7
- symfony/config: ^6.4
- symfony/console: ^6.4.20
- symfony/dependency-injection: ^6.4
- symfony/filesystem: ^6.4
- symfony/http-client: ^6.4
- symfony/validator: ^6.4.20
Requires (Dev)
- phpstan/phpstan: ^2.1.11
- phpunit/phpunit: ^10.5.45
This package is auto-updated.
Last update: 2025-07-26 00:01:12 UTC
README
A powerful PHP library that generates code based on ATProto lexicons. Blugen reads lexicon JSON files and generates corresponding PHP classes with proper namespacing, type definitions, and structure following PSR standards.
🚨 Under Development
This package is currently under active development.
For production use, please refer to official releases only. The main branch may contain unstable features and breaking changes.
Features
- 🚀 Automated Code Generation: Generate PHP classes from ATProto lexicon definitions
- 📁 Smart Namespacing: Automatic PHP namespace resolution from lexicon paths
- 🔧 Multi-file Generation: Support for generating multiple related classes from single lexicons
- ⚡ CLI Interface: Easy-to-use command-line interface for code generation
- 📋 PSR Compliant: Follows PSR-4 autoloading and PSR coding standards
- 🔍 Type Safety: Generates type-safe PHP classes with proper docblocks
Installation
Using Composer
composer require shahmal1yev/blugen
Development Installation
git clone https://github.com/shahmal1yev/blugen.git
cd blugen
composer install
Quick Start
Basic Usage
Generate PHP classes from ATProto lexicons:
./bin/blugen generate
Configuration
Default configuration is stored in config/codegen.php
:
return [ 'lexicons' => [ 'source' => __DIR__ . "/../atproto/lexicons", ], 'output' => [ 'base_namespace' => "BlugenGenerator\\", ], ];
Development
Running Tests
composer test # or vendor/bin/phpunit
Static Analysis
vendor/bin/phpstan analyse
Development Commands
# Install dependencies composer install # Run tests composer test # Generate code from lexicons ./bin/blugen generate
Configuration
Custom Configuration
Create a custom configuration file:
// config/custom.php return [ 'lexicons' => [ 'source' => __DIR__ . "/lexicons", ], 'output' => [ 'base_namespace' => "Codegen\\", ], ];
Contributing
We welcome contributions! Please see CONTRIBUTING.md for details.
Development Setup
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes
- Run tests:
composer test
- Run static analysis:
vendor/bin/phpstan analyse
- Commit changes:
git commit -m 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Submit a pull request
Coding Standards
- Follow PSR-12 coding standards
- Write comprehensive tests
- Document public APIs
Requirements
- PHP 8.1 or higher
- Composer
License
This project is licensed under the MIT License. See LICENSE for details.
Support
Made with ❤️ by the @shahmal1yev. Built for the ATProto ecosystem.