Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2b500d0
Fix array to string conversion warning in Request::getSize()
ChiragAgg5k Dec 11, 2025
2c652b6
Merge pull request #195 from utopia-php/fix-array-header-size-calcula…
ChiragAgg5k Dec 11, 2025
b73e9e8
feat: remove validators and use utopia validators lib
ChiragAgg5k Dec 18, 2025
3571c49
Merge pull request #199 from utopia-php/feat-remove-validator
abnegate Dec 18, 2025
396a8e3
Convert hostname to lowercase (#214)
hmacr Feb 19, 2026
d60c9ce
chore: bump validators lib (#218)
ChiragAgg5k Feb 25, 2026
d2db9f3
Use utopia-php/di for resource injection
ChiragAgg5k Mar 10, 2026
a586863
Move resource ownership into utopia-php/di
ChiragAgg5k Mar 10, 2026
0991a26
Update DI branch dependency
ChiragAgg5k Mar 10, 2026
bf94cd2
update getting started
ChiragAgg5k Mar 10, 2026
82d7481
update
ChiragAgg5k Mar 11, 2026
7996ee1
update
ChiragAgg5k Mar 12, 2026
890f2d3
update appwrite base version
ChiragAgg5k Mar 12, 2026
44b1028
update to use php 8.2
ChiragAgg5k Mar 12, 2026
5bc45e3
fix: restore php 8.2 test runtime
ChiragAgg5k Mar 12, 2026
a4c9cfd
chore: use container scopes
ChiragAgg5k Mar 12, 2026
6240285
remove utopia keyword
ChiragAgg5k Mar 12, 2026
6fd0984
remove optional container in run
ChiragAgg5k Mar 12, 2026
ec4c1ff
remove optional container in run
ChiragAgg5k Mar 12, 2026
f1020e7
renaming
ChiragAgg5k Mar 12, 2026
9616993
remove public getContainer
ChiragAgg5k Mar 12, 2026
233c235
fix getcontainer
ChiragAgg5k Mar 12, 2026
a39c96e
fix getcontainer
ChiragAgg5k Mar 12, 2026
38fecf6
update
ChiragAgg5k Mar 12, 2026
ca7fe25
remove tests
ChiragAgg5k Mar 12, 2026
c942103
make public
ChiragAgg5k Mar 12, 2026
1fadb9c
remove tests
ChiragAgg5k Mar 12, 2026
664436b
add scoped request containers
ChiragAgg5k Mar 13, 2026
b872c6b
cleanup
ChiragAgg5k Mar 13, 2026
bd9526b
feat: request scopes
loks0n Mar 13, 2026
bcb4562
fixes
ChiragAgg5k Mar 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'

- name: Validate composer.json and composer.lock
run: composer validate --strict
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile.fpm
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ RUN composer install --ignore-platform-reqs --optimize-autoloader \
--no-plugins --no-scripts --prefer-dist \
`if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi`

FROM php:8.0-cli-alpine as final
FROM php:8.2-fpm-alpine as final
LABEL maintainer="team@appwrite.io"

ENV DEBIAN_FRONTEND=noninteractive \
PHP_VERSION=8
PHP_FPM_POOL_CONF=/usr/local/etc/php-fpm.d/www.conf

RUN \
apk add --no-cache --virtual .deps \
supervisor php$PHP_VERSION php$PHP_VERSION-fpm php$PHP_VERSION-mbstring nginx bash
supervisor nginx bash


# Nginx Configuration (with self-signed ssl certificates)
COPY ./tests/docker/nginx.conf /etc/nginx/nginx.conf

# PHP Configuration
RUN mkdir -p /var/run/php
COPY ./tests/docker/www.conf /etc/php/$PHP_VERSION/fpm/pool.d/www.conf
COPY ./tests/docker/www.conf /usr/local/etc/php-fpm.d/www.conf

# Script
COPY ./tests/docker/start /usr/local/bin/start
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.swoole
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN composer install --ignore-platform-reqs --optimize-autoloader \
--no-plugins --no-scripts --prefer-dist \
`if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi`

FROM appwrite/base:0.4.3 as final
FROM appwrite/base:0.5.0 as final
LABEL maintainer="team@appwrite.io"

WORKDIR /usr/src/code
Expand Down
41 changes: 26 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Utopia HTTP is a PHP MVC based framework with minimal must-have features for professional, simple, advanced and secure web development. This library is maintained by the [Appwrite team](https://appwrite.io).

Utopia HTTP is dependency-free. Any extra features, such as authentication or caching are available as standalone models in order to keep the framework core clean, light, and easy to learn.
Utopia HTTP keeps routing and request lifecycle concerns separate from resource wiring by relying on the standalone Utopia DI package for dependency injection.

## Getting Started

Expand All @@ -23,11 +23,14 @@ Init your first application in `src/server.php`:
```php
require_once __DIR__.'/../vendor/autoload.php';

use Utopia\DI\Container;
use Utopia\Http\Http;
use Utopia\Http\Request;
use Utopia\Http\Response;
use Utopia\Http\Adapter\FPM\Server;

$container = new Container();

Http::get('/hello-world') // Define Route
->inject('request')
->inject('response')
Expand All @@ -43,7 +46,7 @@ Http::get('/hello-world') // Define Route

Http::setMode(Http::MODE_TYPE_PRODUCTION);

$http = new Http(new Server(), 'America/New_York');
$http = new Http(new Server(), 'America/New_York', $container);
$http->start();
```

Expand All @@ -66,10 +69,13 @@ The library supports server adapters to be able to run on any PHP setup. You cou
#### Use PHP FPM server

```php
use Utopia\DI\Container;
use Utopia\Http\Http;
use Utopia\Http\Response;
use Utopia\Http\Adapter\FPM\Server;

$container = new Container();

Http::get('/')
->inject('response')
->action(
Expand All @@ -78,7 +84,7 @@ Http::get('/')
}
);

$http = new Http(new Server(), 'America/New_York');
$http = new Http(new Server(), 'America/New_York', $container);
$http->start();
```

Expand All @@ -87,11 +93,14 @@ $http->start();
#### Using Swoole server

```php
use Utopia\DI\Container;
use Utopia\Http\Http;
use Utopia\Http\Request;
use Utopia\Http\Response;
use Utopia\Http\Adapter\Swoole\Server;

$container = new Container();

Http::get('/')
->inject('request')
->inject('response')
Expand All @@ -101,7 +110,7 @@ Http::get('/')
}
);

$http = new Http(new Server('0.0.0.0', '80'), 'America/New_York');
$http = new Http(new Server('0.0.0.0', '80'), 'America/New_York', $container);
$http->start();
```

Expand Down Expand Up @@ -208,35 +217,37 @@ Groups are designed to be actions that run during the lifecycle of requests to e

### Resources

Resources allow you to prepare dependencies for requests such as database connection or the user who sent the request. A new instance of a resource is created for every request.
Resources allow you to prepare dependencies for requests such as database connections or shared services. Register application dependencies on the DI container with `set()`. Runtime values such as `request`, `response`, `route`, `error`, and `context` are scoped by `Http` for each request.

Define a resource:
Define a dependency on the DI container:

```php
Http::setResource('timing', function() {
$container->set('bootTime', function () {
return \microtime(true);
});
```

Inject resource into endpoint action:

```php
$http = new Http(new Server(), 'America/New_York', $container);

Http::get('/')
->inject('timing')
->inject('bootTime')
->inject('response')
->action(function(float $timing, Response $response) {
$response->send('Request Unix timestamp: ' . \strval($timing));
->action(function(float $bootTime, Response $response) {
$response->send('Process started at: ' . \strval($bootTime));
});
```

Inject resource into a hook:

```php
Http::shutdown()
->inject('timing')
->action(function(float $timing) {
$difference = \microtime(true) - $timing;
\var_dump("Request took: " . $difference . " seconds");
->inject('bootTime')
->action(function(float $bootTime) {
$uptime = \microtime(true) - $bootTime;
\var_dump("Process uptime: " . $uptime . " seconds");
});
```

Expand All @@ -248,7 +259,7 @@ To learn more about architecture and features for this library, check out more i

## System Requirements

Utopia HTTP requires PHP 8.1 or later. We recommend using the latest PHP version whenever possible.
Utopia HTTP requires PHP 8.2 or later. We recommend using the latest PHP version whenever possible.

## More from Utopia

Expand Down
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@
"bench": "vendor/bin/phpbench run --report=benchmark"
},
"require": {
"php": ">=8.0",
"php": ">=8.2",
"utopia-php/di": "0.3.*",
"utopia-php/validators": "0.2.*",
"ext-swoole": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.5.25",
"doctrine/instantiator": "^1.5",
"laravel/pint": "1.*",
"swoole/ide-helper": "4.8.3",
"phpbench/phpbench": "^1.2",
"phpstan/phpstan": "1.*",
"phpbench/phpbench": "^1.2"
"phpunit/phpunit": "^9.5.25",
"swoole/ide-helper": "4.8.3"
}
}
Loading
Loading