hamza-wakrim/laro-zero
Composer 安装命令:
composer create-project hamza-wakrim/laro-zero
包简介
The skeleton application for the Laro-zero API framework.
关键字:
README 文档
README
A lightweight, API-only Laravel framework fork optimized for building RESTful APIs and microservices.
About Laro-Zero
Laro-Zero is a streamlined version of Laravel, specifically designed for API development. Built on top of the hamza-wakrim/api-framework, it removes all frontend dependencies and view-related components, making it perfect for:
- RESTful API development
- Microservices architecture
- Mobile app backends
- Single Page Application (SPA) backends
- Headless CMS implementations
Features
- API-First Design: Optimized exclusively for API endpoints
- Lightweight: Removed all frontend build tools and dependencies
- Fast Setup: Minimal configuration required
- Laravel Compatibility: Built on Laravel's robust foundation
- Modern PHP: Requires PHP 8.2 or higher
- Enforced Design Pattern: Strict Route → Controller → Service → Model architecture
Enforced Design Pattern
Laro-Zero enforces a strict layered architecture pattern that all developers must follow:
Route → Controller → Service → Model
Pattern Rules
-
Routes (
routes/api.php)- MUST only call Controllers
- NEVER call Services or Models directly
- Handle HTTP routing only
-
Controllers (
app/Http/Controllers/)- MUST only call Services
- NEVER call Models directly
- Handle HTTP concerns (request/response, validation)
- All Controllers extend
App\Http\Controllers\Controller
-
Services (
app/Services/)- Handle ALL business logic
- Interact with Models
- All Services extend
App\Services\Service - Must be in
App\Servicesnamespace and end withService
-
Models (
app/Models/)- Represent database entities only
- No business logic
- Eloquent ORM models
Enforcement Mechanisms
- Base Service Class: All services must extend
App\Services\Service - Base Controller Class: Includes
validateService()method to ensure proper service injection - Code Structure: Directory structure and naming conventions enforce the pattern
- Documentation: Extensive PHPDoc comments explain the pattern
Example Implementation
// routes/api.php Route::get('/examples', [ExamplesController::class, 'index']); // app/Http/Controllers/ExamplesController.php class ExamplesController extends Controller { public function __construct( private ExampleService $exampleService ) { $this->validateService($exampleService); } public function index(): JsonResponse { $users = $this->exampleService->getAllUsers(); return response()->json($users); } } // app/Services/ExampleService.php class ExampleService extends Service { public function getAllUsers() { return Examples::all(); // Interacts with Model } } // app/Models/Examples.php class Examples extends Model { // Model definition only }
Why This Pattern?
- Separation of Concerns: Each layer has a single responsibility
- Testability: Easy to mock services in controllers, models in services
- Maintainability: Business logic is centralized in services
- Scalability: Easy to add new features following the same pattern
- Consistency: All code follows the same structure
Creating New Features
When adding new features, follow these steps:
-
Create the Model (if needed)
php artisan make:model Product
-
Create the Service
php artisan make:service ProductService
Then extend
App\Services\Serviceand add business logic methods. -
Create the Controller
php artisan make:controller ProductController
Then inject the service in the constructor and call service methods.
-
Add Routes
Route::prefix('products')->group(function () { Route::get('/', [ProductController::class, 'index']); // ... more routes });
Requirements
- PHP >= 8.2
- Composer
- Node.js (optional, only for development scripts)
Installation
Via Composer
composer create-project hamza-wakrim/laro-zero your-project-name
Manual Installation
- Clone the repository:
git clone https://github.com/hamza-wakrim/laro-zero.git
cd laro-zero
- Install dependencies:
composer install
- Set up environment:
cp .env.example .env php artisan key:generate
- Run migrations:
php artisan migrate
Quick Start
- Start the development server:
php artisan serve
-
Access the API:
- Health check:
http://localhost:8000/api/health - API routes:
http://localhost:8000/api/*
- Health check:
-
Development mode (with queue and logs):
composer run dev
Project Structure
laro-zero/
├── app/ # Application code
│ ├── Http/
│ │ └── Controllers/ # API Controllers (call Services only)
│ ├── Services/ # Business logic layer (call Models)
│ ├── Models/ # Eloquent Models (database entities)
│ └── Providers/ # Service Providers
├── routes/
│ ├── api.php # API routes (call Controllers only)
│ └── console.php # Artisan commands
├── config/ # Configuration files
├── database/ # Migrations, factories, seeders
└── tests/ # PHPUnit tests
Important: The directory structure enforces the design pattern:
routes/api.php→ callsapp/Http/Controllers/app/Http/Controllers/→ callsapp/Services/app/Services/→ callsapp/Models/
API Routes
All API routes are defined in routes/api.php. By default, routes are prefixed with /api.
Remember: Routes MUST only call Controllers, never Services or Models directly.
Example:
// ✅ CORRECT: Route calls Controller Route::get('/users', [UserController::class, 'index']); // ❌ WRONG: Route calls Service directly Route::get('/users', function () { return UserService::getAllUsers(); // DON'T DO THIS }); // ❌ WRONG: Route calls Model directly Route::get('/users', function () { return User::all(); // DON'T DO THIS });
Available Commands
composer setup- Install dependencies and set up the projectcomposer dev- Start development server with queue and logscomposer test- Run PHPUnit testsphp artisan serve- Start the development serverphp artisan migrate- Run database migrations
Configuration
Key configuration files:
config/app.php- Application configurationconfig/database.php- Database settingsconfig/auth.php- Authentication settings
Testing
Run tests with:
composer test
Or directly with PHPUnit:
php artisan test
Framework
This project uses hamza-wakrim/api-framework as its core framework, which is a Laravel fork optimized for API development.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
The Laro-Zero framework is open-sourced software licensed under the MIT license.
Support
For issues and questions, please open an issue on the GitHub repository.
hamza-wakrim/laro-zero 适用场景与选型建议
hamza-wakrim/laro-zero 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 11 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「rest」 「api」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 hamza-wakrim/laro-zero 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hamza-wakrim/laro-zero 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 hamza-wakrim/laro-zero 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
A PSR-7 compatible library for making CRUD API endpoints
Api bundle
A Flickr wrapper to allow you to call the Flickr api with Guzzle as the backend.Goal is to have 100% Flickr api coverage rather than just upload/display photos (currently at 23%).
High-performance, opinionated PHP 8 web framework with O(1) routing, parallel async MySQL, type-safe asset bridge, and React-island frontend
BlockCypher's PHP SDK for REST API
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-18