Download the PHP package nameless/laravel-api-generator without Composer
On this page you can find all versions of the php package nameless/laravel-api-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nameless/laravel-api-generator
More information about nameless/laravel-api-generator
Files in nameless/laravel-api-generator
Package laravel-api-generator
Short Description A professional Laravel API generator that automatically creates complete API structures with clean architecture, type safety, and best practices
License MIT
Informations about the package laravel-api-generator
Laravel API Generator
Laravel API Generator is a professional, enterprise-grade Laravel package that generates complete API structures following best practices and clean architecture principles.
๐ Features
โจ Complete API Generation
- Models with proper relationships and fillable properties
- RESTful Controllers with full CRUD operations
- Service Layer implementation for business logic
- Data Transfer Objects (DTOs) for type-safe data handling
- Form Request Validations with intelligent rules
- API Resources for consistent response formatting
- Policies for authorization
- Database Factories with realistic fake data
- Seeders for test data generation
- Migrations with proper foreign keys and constraints
๐๏ธ Architecture & Design Patterns
- Clean Architecture with separated concerns
- Repository Pattern with service layer
- Value Objects for domain modeling
- Dependency Injection throughout
- SOLID Principles compliance
- Type Safety with PHP 8.1+ features
๐ง Advanced Features
- JSON Schema Support for bulk generation
- Relationship Management (One-to-One, One-to-Many, Many-to-Many)
- Inheritance Support for model hierarchies
- Custom Field Types with validation rules
- Extensible Generator System
- Professional Error Handling
- Delete generated API structures with a single command
๐ฆ Installation
You can install the package via Composer:
The package automatically registers its service provider.
๐ฏ Quick Start
Single Entity Generation
Generate a complete API for a single entity:
This creates:
app/Models/User.php
app/Http/Controllers/UserController.php
app/Http/Requests/UserRequest.php
app/Http/Resources/UserResource.php
app/Services/UserService.php
app/DTO/UserDTO.php
app/Policies/UserPolicy.php
database/factories/UserFactory.php
database/seeders/UserSeeder.php
database/migrations/xxxx_create_users_table.php
- API routes in
routes/api.php
Bulk Generation from JSON
Create a class_data.json
file in your project root:
Then run:
Delete Generated API
Remove all generated files for an entity:
๐๏ธ Architecture Overview
Service Layer Pattern
The generated code follows the Service Layer pattern for better organization:
Data Transfer Objects
Type-safe data handling with DTOs:
๐ ๏ธ Advanced Usage
Custom Field Types
Supported field types:
string
- VARCHAR(255)text
- TEXTinteger
/int
- INTEGERbigint
- BIG INTEGERboolean
/bool
- BOOLEANfloat
/decimal
- DECIMALjson
- JSONdate
- DATEdatetime
- DATETIMEtimestamp
- TIMESTAMPuuid
- UUID
Relationship Types
The generator supports all Laravel relationship types:
- One-to-One:
oneToOneRelationships
- One-to-Many:
oneToManyRelationships
- Many-to-One:
manyToOneRelationships
- Many-to-Many:
manyToManyRelationships
Model Inheritance
Support for model inheritance:
Generated File Structure
This command generates:
- Models (
App\Models
) - Controllers (
App\Http\Controllers
) - Services (
App\Services
) - DTOs (
App\DTO
) - Policies (
App\Policies
) - Requests (
App\Http\Requests
) - Resources (
App\Http\Resources
) - Factories (
Database\Factories
) - Migrations (
Database\Migrations
) - Seeders (
Database\Seeders
)
Delete API Structure
To remove the generated API structure, you can use:
This will remove all the generated files from the API structure.
To delete a specific model's API structure, use:
For example:
This will delete all the generated files related to the Post model, including controllers, services, DTOs, policies, resources, factories, seeders, and migrations.
๐ง Configuration
Custom Stubs
You can customize the generated code by publishing and modifying the stubs:
Service Registration
The package automatically registers all generators and services through dependency injection.
๐งช Testing
Run static analysis:
Format code:
๐ API Documentation
The package integrates with Scramble for automatic API documentation generation.
After generating your APIs, visit /docs/api
to see the generated documentation.
Generated Structure
Modern Controller Example
Service
DTO
Model
Resource
Request
Factory
Seeder
Policy
Migration
๐ค Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
๐ Testing
Run the test suite:
Run static analysis:
Format code:
๐ Local Development
-
Clone this repository:
-
Install dependencies:
- Run tests:
Testing in a Laravel Project
-
In your Laravel project's
composer.json
, add: - Run:
๐ Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
๐ Credits
- Author: Mbassi Loรฏc Aron
- Email: [email protected]
๐ Changelog
Please see CHANGELOG.md for more information on what has changed recently.
๐ก Why Choose Laravel API Generator?
โ
Professional Architecture - Built with enterprise-grade patterns
โ
Type Safety - Full PHP 8.1+ type declarations
โ
Clean Code - SOLID principles and clean architecture
โ
Extensible - Easy to extend with custom generators
โ
Well Tested - Comprehensive test suite
โ
Documentation - Complete API documentation generation
โ
Best Practices - Follows Laravel and PHP best practices
Transform your Laravel development workflow with professional API generation!
๐ License
This package is open-source and distributed under the MIT License. See the LICENSE file for more details.