Skip to content

Commit 409a258

Browse files
authored
Backport abstract request/response with adapters (#212)
1 parent decfa49 commit 409a258

33 files changed

+1481
-270
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Init your first application:
2121
```php
2222
require_once __DIR__ . '/../../vendor/autoload.php';
2323

24-
use Utopia\Http;
25-
use Utopia\Request;
26-
use Utopia\Response;
24+
use Utopia\Http\Http;
25+
use Utopia\Http\Adapter\FPM\Request;
26+
use Utopia\Http\Adapter\FPM\Response;
2727

2828
Http::get('/hello-world') // Define Route
2929
->inject('request')
@@ -54,9 +54,9 @@ There are three types of hooks, init hooks, shutdown hooks and error hooks. Init
5454
```php
5555
require_once __DIR__ . '/../../vendor/autoload.php';
5656

57-
use Utopia\Http;
58-
use Utopia\Request;
59-
use Utopia\Response;
57+
use Utopia\Http\Http;
58+
use Utopia\Http\Adapter\FPM\Request;
59+
use Utopia\Http\Adapter\FPM\Response;
6060

6161
Http::init()
6262
->inject('response')

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
"utopia-php/validators": "0.2.*"
2929
},
3030
"require-dev": {
31-
"phpunit/phpunit": "9.*",
3231
"laravel/pint": "1.*",
32+
"phpbench/phpbench": "1.*",
3333
"phpstan/phpstan": "1.*",
34-
"phpbench/phpbench": "1.*"
34+
"phpunit/phpunit": "9.*",
35+
"swoole/ide-helper": "^6.0"
3536
},
3637
"config": {
3738
"allow-plugins": {

composer.lock

Lines changed: 39 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/Getting-Starting-Guide.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ If you’re new to Utopia, let’s get started by looking at an example of a bas
99
## Basic GET Route
1010

1111
```php
12-
use Utopia\Http;
13-
use Utopia\Swoole\Request;
14-
use Utopia\Swoole\Response;
12+
use Utopia\Http\Http;
13+
use Utopia\Http\Adapter\Swoole\Request;
14+
use Utopia\Http\Adapter\Swoole\Response;
1515
use Swoole\Http\Server;
1616
use Swoole\Http\Request as SwooleRequest;
1717
use Swoole\Http\Response as SwooleResponse;
@@ -26,6 +26,7 @@ Http::get('/')
2626
// Return raw HTML
2727
$response->send("<div> Hello World! </div>");
2828
}
29+
);
2930
/*
3031
Configure your HTTP server to respond with the Utopia app.
3132
*/
@@ -138,9 +139,9 @@ You can find the details of other status codes by visiting our [GitHub repositor
138139
Let's make the above example slightly advanced by adding more properties.
139140

140141
```php
141-
use Utopia\Http;
142-
use Utopia\Swoole\Request;
143-
use Utopia\Swoole\Response;
142+
use Utopia\Http\Http;
143+
use Utopia\Http\Adapter\Swoole\Request;
144+
use Utopia\Http\Adapter\Swoole\Response;
144145
use Swoole\Http\Server;
145146
use Swoole\Http\Request as SwooleRequest;
146147
use Swoole\Http\Response as SwooleResponse;

src/Http/Adapter/Adapter.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Utopia\Http\Adapter;
4+
5+
abstract class Adapter
6+
{
7+
abstract public function onStart(callable $callback);
8+
abstract public function onRequest(callable $callback);
9+
abstract public function start();
10+
}

0 commit comments

Comments
 (0)