larium/framework
最新稳定版本:1.1.0
Composer 安装命令:
composer require larium/framework
包简介
A PSR-15 framework.
关键字:
README 文档
README
A lightweight PSR-15 compliant framework for building HTTP applications with middleware support and dependency injection.
Requirements
- PHP 8.2, 8.3, or 8.4
- Composer
- Docker (for development environment)
Installation
As a Composer Package (Recommended)
Install the framework as a dependency in your project:
composer require larium/framework
Development Setup
If you want to contribute to the framework or run it locally:
-
Clone the repository:
git clone git@github.com:Larium/framework.git cd framework -
Install dependencies:
composer install
Development Environment
This project uses Docker for consistent development environments across different PHP versions.
Using Make Commands
The project includes several make commands for common development tasks:
Docker Environment Setup
make docker-build- Build Docker image for PHP 8.4make docker-build-8.3- Build Docker image for PHP 8.3make docker-build-8.2- Build Docker image for PHP 8.2
Dependency Management
make composer-update- Update dependencies using PHP 8.4 Docker containermake composer-update-8.3- Update dependencies using PHP 8.3 Docker containermake composer-update-8.2- Update dependencies using PHP 8.2 Docker container
Testing
make run-tests- Run tests using PHP 8.4 Docker containermake run-tests-8.3- Run tests using PHP 8.3 Docker containermake run-tests-8.2- Run tests using PHP 8.2 Docker container
Manual Setup (without Docker)
If you prefer to work without Docker:
-
Install PHP 8.2+ with required extensions:
- bcmath
- zip
- xdebug (for development)
-
Install Composer if not already installed:
curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer -
Install dependencies:
composer install
-
Run tests:
./vendor/bin/phpunit tests/
Usage Example
<?php # public/index.php declare(strict_types = 1); use Larium\Framework\Framework; use Larium\Framework\Middleware\RoutingMiddleware; use Laminas\Diactoros\ServerRequestFactory; use Larium\Framework\Middleware\ActionResolverMiddleware; use Larium\Framework\Provider\ContainerProvider; require_once __DIR__ . '/../vendor/autoload.php'; (function () { /** @var ContainerProvider [implement the ContainerProvider interface] */ $containerProvider $container = $containerProvider->getContainer(); $f = new Framework($container); $f->pipe(RoutingMiddleware::class, 1); $f->pipe(ActionResolverMiddleware::class, 0); $f->run(ServerRequestFactory::fromGlobals()); })();
Project Structure
src/- Framework source codetests/- Test suite.docker/- Docker configuration for different PHP versionsbuild/- Build artifacts and coverage reportsvendor/- Composer dependencies
Testing
Run the test suite using one of these methods:
Using Make (recommended):
make run-tests
Using PHPUnit directly:
./vendor/bin/phpunit tests/
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
make run-tests - Submit a pull request
License
MIT License - see LICENSE file for details.
统计信息
- 总下载量: 1.2k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-16