fm-labs / flowphp
PHP micro framework.
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/fm-labs/flowphp
Requires
- php: ^7.1|^8.0
- ext-json: *
- fm-labs/php-uri: ^0.6
- psr/container: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
- php-pm/php-pm: ^2.0
- phpunit/phpunit: ^7|^8|^9
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2025-09-29 02:42:50 UTC
README
PHP micro framework
Requirements
- php 7.0+
Installation
$ cd /my/project/dir $ composer require fm-labs/flowphp dev-master
Core Concepts
Global- Manages singletons and global config. Provides static convenience helpersApplication- Wires configuration, routes and middlewareRouter- Wires routes with handlersController- Processes server requestsTemplate- Renders parameterized templates php-styleView- Template + Layout templateManager- Manages named object instances of configured adapters- Database
- Cache
- Log
RouteHandler- Any callable that MAY produce on of the following results:ResponseInterfaceRouteHandler: Will be invoked recursively with updated route contextClosure: Treated as a RouteHandlerString: Will be applied as response bodyNull: Fallback handling. Not implemented yetOther: Throws exception
Components
HTTP Stack
Messages(Request/Response) - Complaint to PSR-7,Handler- Complaint to PSR-15Factory- Complaint to PSR-17Server- for processingHTTP MessagesusingHTTP HandlersandHTTP FactoriesMiddlewareQueue- for processing multiple request handlers
Application
The application is the main object we are working when building a project based on FlowPHP. All the wiring of the configuration, components and routes happens here.
Basically the application acts as a Service Container and Server Request Handler. The standard application has 3 main components: Configuration, Router and Middleware.
Middleware
Built-in middlewares:
ErrorMiddleware- Error handlingRoutingMiddleware- Route matching and handlingRequestMapperMiddleware- Build response based on requestCorsMiddleware- CORS handling
Routing
Simple Router
- String templates
- Named args
- Optional args
- Pass args - Arguments that will be passed to the request handler as function arguments
- Custom regex for arg matching
Templating
Simple Template Engine
$template = (new Template()) ->set('myvar', 'myval') ->setTemplate('mytemplate'); // resolves to ./templates/mytemplate.phtml $html = $template->render();
Examples
Run tests
$ composer run-script test // or $ composer run-script test-verbose // or $ ./vendor/bin/phpunit --bootstrap tests/bootstrap.php tests/
TODO
- App: Controller
- App: Plugins
- Routing: Nested routers
- Template: Helpers
- Http/Server: Cookie support
- Http/Server: Uploaded files support