mpie22 / framework
A PHP framework that supports openswoole/workerman/cli-server/FPM environments.
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.0
- monolog/monolog: ^2.8
- mpie22/core: dev-main
- nunomaduro/collision: ^6.3
- spatie/ignition: ^1.3
- symfony/console: ^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.11
- openswoole/ide-helper: ~4.11.0
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-12-05 22:51:40 UTC
README
Mpie Framework Starter
Lightweight • Simple • Fast
A componentized lightweight PHP
framework that supports swoole, workerman, and FPM environments. It can be used for API
development, which is convenient and fast. The framework has the session
and view
extensions installed by default, and can be removed directly if not needed.
Environmental requirements
- PHP >= 8.0
- ext-ctype
- ext-dom
- ext-filter
- ext-json
- ext-libxml
- ext-mbstring
- ext-openssl
- ext-openswoole
- ext-pcntl
- ext-pdo
- ext-phar
- ext-redis
- ext-tokenizer
- ext-xml
- ext-xmlwriter
If you use openswoole, be sure to install version 4.8 or above, if you use workerman, be sure to use version 4.0 or above
use
Install
composer create-project mpie22/framework:dev-main
Start the service
swoole service
php bin/openswoole.php // asynchronous mode php bin/openswoole-co.php // coroutine mode
workerman service
php bin/workerman.php start
Built-in services
php bin/cli-server.php
FPM mode, direct the request to public/index.php
the difference
Using swoole/workerman to support annotations, AOP and other features, FPM mode can directly uninstall AOP packages.
Getting started
route definition
Annotation definitions can be used under swoole/swooleco/workerman
<?php namespace App\Controllers; use App\Http\Response; use Mpie\Routing\Annotation\Controller; use Mpie\Routing\Annotation\GetMapping; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; #[Controller(prefix: '/')] class IndexController { #[GetMapping(path: '/')] public function index(ServerRequestInterface $request): ResponseInterface { return Response::HTML('Hello, ' . $request->query('name', 'MpiePHP!')); } }
The above request 0.0.0.0:8080
will point to the index
method, the controller method supports dependency injection, if you need an example of the current request, the request parameter name must be request
, other routing parameters will be injected, the controller method An instance of ResponseInterface
needs to be returned.
Annotations cannot be used under FPM or built-in services
Route definitions are defined in the map
method of the App\Http\Kernel
class
$router->middleware(TestMiddleware::class)->group(function(Router $router) { $router->get('/', [IndexController::class, 'index']); $router->get('/test', function(\Psr\Http\Message\ServerRequestInterface $request) { return \App\Http\Response::HTML('new'); }); });