elliephp/framework
Composer 安装命令:
composer require elliephp/framework
包简介
A fast, modular PHP microframework focused on clean architecture, performance, and zero-bloat components.
README 文档
README
A fast, modular PHP microframework focused on clean architecture, performance, and zero-bloat components.
Requirements
- PHP 8.4 or higher
- Composer
- PDO extension
Installation
composer install
cp .env.example .env
Quick Start
1. Configure Environment
Edit .env file with your settings:
APP_NAME='ElliePHP'
APP_DEBUG=true
APP_TIMEZONE='UTC'
CACHE_DRIVER=file
2. Define Routes
Routes are defined in routes/router.php:
use ElliePHP\Application\Http\Controllers\WelcomeController;use ElliePHP\Components\Routing\Router;
Router::get('/', WelcomeController::class);
Router::post('/api/users', [UserController::class, 'create']);
3. Create Controllers
Controllers live in app/Controllers/:
namespace ElliePHP\Application\Controllers;
use Psr\Http\Message\ResponseInterface;
final readonly class WelcomeController
{
public function process(): ResponseInterface
{
return response()->json([
'message' => 'Hello World'
]);
}
}
4. Add Middleware
Register global middleware in app/Configs/Middleware.php:
return [
'global_middlewares' => [
LoggingMiddleware::class,
CorsMiddleware::class,
],
];
Dependency Injection
ElliePHP uses PHP-DI for automatic dependency injection. Controllers and services get their dependencies automatically:
final readonly class UserController
{
public function __construct(
private UserService $userService
) {
}
public function index(): ResponseInterface
{
$users = $this->userService->getAllUsers();
return response()->json(['users' => $users]);
}
}
Configure bindings in configs/Container.php. See docs/DEPENDENCY_INJECTION.md for details.
Helper Functions
Container
container(); // Get container instance
container(UserService::class); // Resolve service
Environment Variables
env('APP_NAME'); // Get environment variable
env('APP_DEBUG', false); // With default value
Configuration
config('middleware.global_middlewares'); // Get config value
config(['app.name' => 'MyApp']); // Set config values
HTTP
request(); // Get current request
response(200)->json(['data' => $data]); // Create JSON response
Caching
cache()->set('key', 'value', 3600); // Cache for 1 hour
cache()->get('key', 'default'); // Get cached value
cache('redis')->set('key', 'value'); // Use specific driver
Logging
report()->info('User logged in', ['user_id' => 123]);
report()->error('Something went wrong');
report()->exception($exception);
Path Helpers
root_path('config/app.php');
app_path('Controllers/UserController.php');
storage_path('logs/app.log');
routes_path('api.php');
Cache Drivers
Supported cache drivers:
file- File-based caching (default)redis- Redis cachingsqlite- SQLite database cachingapcu- APCu memory caching
Configure in .env:
CACHE_DRIVER=redis
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
Directory Structure
├── app/
│ ├── Configs/ # Configuration files
│ ├── Controllers/ # HTTP controllers
│ ├── Middlewares/ # Custom middleware
│ └── Services/ # Business logic services
├── public/
│ └── index.php # Application entry point
├── routes/
│ └── router.php # Route definitions
├── src/
│ ├── Kernel/ # Framework core
│ └── Support/ # Helper functions
├── storage/
│ ├── Cache/ # Cache files
│ └── Logs/ # Application logs
└── tests/ # Unit tests
Development
Run the built-in PHP server:
php -S localhost:8000 -t public
Visit: http://localhost:8000
Testing
composer test
composer test:coverage
License
MIT License
Support
- Issues: https://github.com/elliephp/framework/issues
- Documentation: https://github.com/elliephp
elliephp/framework 适用场景与选型建议
elliephp/framework 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「microframework」 「routing」 「php」 「http」 「cache」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 elliephp/framework 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 elliephp/framework 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 elliephp/framework 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Write down your routing mapping at one place
A lightweight, secure-by-default PHP microframework built on Slim – providing Laravel-like features (ORM, authentication, migrations, caching) without the bloat. Perfect for building REST APIs and small-to-medium PHP applications.
Flight routing is a simple, fast PHP router that is easy to get integrated with other routers.
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
A router designed for web requests for the Monolith framework
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-18