Point is a lightweight, modular PHP microframework built for flexibility and extensibility.
Point Framework v0.1.0 Stable is published. See the changelog and GitHub Release for release details.
- PSR-7 / PSR-15 / PSR-17 compliant HTTP message handling
- PSR-11 compatible dependency injection container (built-in, with PHP-DI support)
- FastRoute based routing with dynamic parameters and route groups
- Middleware pipeline with FIFO execution order
- Content negotiation for JSON and HTML error responses, with optional XML and plain-text middleware
- Error handling with detailed stack traces in development
- Default PSR-7 implementation via httpsoft (no additional packages required)
- Optional PSR-7 implementations via nyholm/psr7, laminas/laminas-diactoros, guzzlehttp/psr7
- PHP 8.4 / 8.5 native with strict typing
- PHP >= 8.4.27
- Composer 2.x
- Optional XML middleware requires SimpleXML for request parsing or DOM for error rendering.
The release CI matrix covers PHP 8.4.27, PHP 8.4, and PHP 8.5 on Ubuntu and Windows. The Ubuntu Nginx/PHP-FPM job validates a CI fixture; it does not certify a production host or deployment topology.
composer require trypoint/pointPoint includes httpsoft/http-message and httpsoft/http-server-request as the bundled PSR-7/PSR-17 fallback. Automatic discovery can select a complete installed alternative first.
Optional: replace with an alternative PSR-7 implementation:
# Nyholm (fast, lightweight)
composer require nyholm/psr7 nyholm/psr7-server
# Laminas
composer require laminas/laminas-diactoros
# Guzzle
composer require guzzlehttp/psr7<?php
require __DIR__ . '/../vendor/autoload.php';
use Point\Factory\AppFactory;
// Create application
$app = AppFactory::create();
// GET route
$app->get('/', function ($request, $response) {
$response->getBody()->write('Hello, World!');
return $response;
});
// Dynamic route with parameters
$app->get('/user/{id}', function ($request, $response, array $args) {
$response->getBody()->write('User: ' . $args['id']);
return $response;
});
// JSON response
$app->get('/api/users', function ($request, $response) {
$data = [
['id' => 1, 'name' => 'Alice'],
['id' => 2, 'name' => 'Bob'],
];
$response->getBody()->write(json_encode($data));
return $response->withHeader('Content-Type', 'application/json');
});
// Run the application
$app->run();Save as public/index.php and serve with PHP's built-in server:
php -S localhost:8080 -t publicVisit http://localhost:8080/ to see the response.
Moving an existing Slim app? See the Slim migration guide.
$app->get('/users', $handler);
$app->post('/users', $handler);
$app->put('/users/{id}', $handler);
$app->delete('/users/{id}', $handler);
$app->patch('/users/{id}', $handler);
$app->options('/users', $handler);
$app->any('/users', $handler); // Matches any HTTP method$app->get('/users/{id}', function ($request, $response, array $args) {
// $args['id'] contains the matched value
return $response;
});
// Optional parameters
$app->get('/users[/{id}]', $handler);
// Constraints via regex
$app->get('/users/{id:\d+}', $handler); // Only digits$app->group('/api', function ($group) use ($handler) {
$group->get('/users', $handler);
$group->post('/users', $handler);
$group->group('/v1', function ($group) use ($handler) {
$group->get('/posts', $handler);
});
});$app->get('/admin', $handler)->add($authMiddleware);
$app->group('/api', function ($group) use ($rateLimitMiddleware, $handler) {
$group->add($rateLimitMiddleware);
$group->get('/users', $handler);
});$route = $app->get('/user/{id}', $handler)->setName('user.profile');
$urlGenerator = $app->getContainer()->get(\Point\Interfaces\UrlGeneratorInterface::class);
$url = $urlGenerator->urlFor('user.profile', ['id' => 123]); // /user/123Pass raw parameter values. Point percent-encodes each substituted value.
Encoded slashes (%2F and %2f) in request paths return HTTP 404.
Use separate route segments for values that span a slash.
Middleware follows PSR-15 (MiddlewareInterface) and executes in FIFO order (first added = outermost).
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
class ExampleMiddleware implements MiddlewareInterface
{
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
// Before: modify request, add attributes, etc.
$request = $request->withAttribute('startTime', microtime(true));
$response = $handler->handle($request);
// After: modify response, add headers, logging, etc.
$duration = microtime(true) - $request->getAttribute('startTime');
return $response->withHeader('X-Response-Time', (string)$duration);
}
}
// Add to application
$app->add(new ExampleMiddleware());
// Alternatively, register ExampleMiddleware::class in the container and add it by ID.| Middleware | Purpose |
|---|---|
RoutingMiddleware |
Resolves routes, adds RouteMatch to request |
EndpointMiddleware |
Executes matched route handler |
ErrorExceptionMiddleware |
Converts PHP errors to ErrorException |
HtmlExceptionMiddleware |
Renders HTML error pages |
JsonExceptionMiddleware |
Renders JSON error responses |
XmlExceptionMiddleware |
Renders XML error responses |
PlainTextExceptionMiddleware |
Renders plain text error responses |
ExceptionLoggingMiddleware |
Logs exceptions via PSR-3 logger |
HeadMethodMiddleware |
Removes body for HEAD requests |
MethodOverrideMiddleware |
Allows _method parameter override |
ContentLengthMiddleware |
Adds Content-Length for known body sizes, except on HTTP 204 |
OutputBufferingMiddleware |
Captures output buffering |
ResponseFactoryMiddleware |
Short-circuits the pipeline with an empty response |
BasePathMiddleware |
Handles subdirectory deployments |
// Development: detailed errors
$app->addErrorMiddleware(true, true, true);
// Production: minimal errors
$app->addErrorMiddleware(false, true, false, $logger);
// Custom error handler
$app->addErrorMiddleware(
displayErrorDetails: false,
logErrors: true,
logErrorDetails: true,
logger: $customPsr3Logger
);Point includes a PSR-11 compatible container (SimpleContainer) for explicitly registered values, instances, and factories.
$app = AppFactory::create();
$container = $app->getContainer();
// Register an instance and a factory that uses it
$container->set(DateTimeZone::class, new DateTimeZone('UTC'));
$container->set(DateTimeImmutable::class, static function ($c): DateTimeImmutable {
return new DateTimeImmutable('now', $c->get(DateTimeZone::class));
});
$startedAt = $container->get(DateTimeImmutable::class);The factory runs on first lookup, and subsequent lookups return the same result. For an unregistered ID, has() returns false and get() throws Psr\Container\NotFoundExceptionInterface.
Use an external PHP-DI container if your application needs constructor autowiring.
use DI\ContainerBuilder;
use Point\Factory\AppFactory;
use Point\Container\Definition\PointDefinitions;
use Point\Container\Definition\HttpDefinitions;
$builder = new ContainerBuilder();
$builder->addDefinitions((new PointDefinitions())->getDefinitions());
$builder->addDefinitions((new HttpDefinitions())->getDefinitions());
$app = AppFactory::createFromContainer($builder->build())->withDefaults();Point accepts PSR-7 messages and uses PSR-17 factories for server requests, responses, streams, uploaded files, and URIs. The bundled HttpSoft provider is the fallback. Automatic discovery checks for a complete provider in this order: Nyholm (including nyholm/psr7-server), Laminas Diactoros, Guzzle PSR-7, then HttpSoft.
// Bundled HttpSoft provider
$responseFactory = new \HttpSoft\Message\ResponseFactory();
$requestFactory = new \HttpSoft\Message\ServerRequestFactory();Alternative implementations (install separately):
// Nyholm (fast, lightweight)
$psr17 = new \Nyholm\Psr7\Factory\Psr17Factory();
// Laminas
$responseFactory = new \Laminas\Diactoros\ResponseFactory();
$requestFactory = new \Laminas\Diactoros\ServerRequestFactory();
// Guzzle
$factory = new \GuzzleHttp\Psr7\HttpFactory();Pass overrides at bootstrap. Replacing a PSR-17 factory does not replace Point's separate request-from-globals service.
$app = AppFactory::create([
\Psr\Http\Message\ResponseFactoryInterface::class => new \HttpSoft\Message\ResponseFactory(),
]);Use the provider's own request factory for outbound client requests. Point's built-in definitions bind the five server-side factory interfaces listed above.
The v0.1.0 Stable API freeze was approved on 2026-11-28. Documented stable APIs are covered by the approved compatibility policy; explicitly provisional APIs retain their documented behavior for v0.1.0 without a stable compatibility promise. See the API freeze record.
# Run all tests
composer test
# Run static analysis and the configured style check
composer stan
composer cs:checkThe full-tree style command still reports the documented RC.1 baseline exception. Requires development dependencies:
composer installRewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}php -S localhost:8080 -t publicReport vulnerabilities to security.point@madalinmariusstan.dev.
See SECURITY.md for supported versions and disclosure policy.
- Fork the repository
- Create a feature branch
- Ensure tests pass:
composer test:all - Submit a pull request
See CONTRIBUTING.md for detailed guidelines.
MIT License. See LICENSE.md for details.
Copyright (c) 2011-2024 Josh Lockhart (original Slim Framework) Copyright (c) 2024 Madalin Marius Stan (Point Framework)