locky42/leopard-core
最新稳定版本:1.0.5
Composer 安装命令:
composer require locky42/leopard-core
包简介
Lightweight PHP framework core for routing, controllers, and application base.
README 文档
README
leopard-core is the core library for the Leopard Framework, providing essential features such as routing, attributes, dependency injection container, and other foundational components.
Table of Contents
Installation
Install leopard-core using Composer:
composer require locky42/leopard-core
Core Components
Dependency Injection Container
The Container is a simple dependency injection container that allows you to register services and retrieve their instances.
Example:
use Leopard\Core\Container; $container = new Container(); // Register a service $container->set('logger', function () { return new Logger(); }); // Retrieve the service $logger = $container->get('logger');
Routing
The Router allows you to define routes using attributes and handle HTTP requests.
Example:
use Leopard\Core\Router; use Leopard\Core\Attributes\Route; class TestController { #[Route('/test', method: 'GET')] public function test(): string { return "Hello, world!"; } } $router = new Router(); $response = $router->dispatch('/test', 'GET'); echo $response; // Outputs "Hello, world!"
Attributes
leopard-core supports PHP attributes for defining routes and other metadata.
Example:
use Leopard\Core\Attributes\Route; #[Route('/user/{id}', method: 'GET')] public function getUser(string $id): string { return "User ID: $id"; }
Usage Examples
Loading Configuration
use Leopard\Core\Config; $config = new Config(); $config->load(__DIR__ . '/config/app.yaml'); echo $config->get('database.host'); // Outputs 'localhost'
Testing
To run tests, use the following command:
./run-tests.sh
The tests are located in the vendor/locky42/leopard-core/tests directory.
License
This project is licensed under the MIT License.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-24