Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving swoole to a dev dependency #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ $http->start();

> When using Swoole, you can use the command `php src/server.php` to run the HTTP server locally, but you need Swoole installed. For setup with Docker, check out our [example application](/example)

### Parameters
### Parameters

Parameters are used to receive input into endpoint action from the HTTP request. Parameters could be defined as URL parameters or in a body with a structure such as JSON.

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
},
"require": {
"php": ">=8.0",
"ext-swoole": "*",
"utopia-php/servers": "0.1.*"
},
"require-dev": {
"ext-xdebug": "*",
"ext-swoole": "*",
"phpunit/phpunit": "^9.5.25",
"laravel/pint": "^1.2",
"swoole/ide-helper": "4.8.3",
Expand Down
30 changes: 15 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions example/src/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
->param('name', 'World', new Text(256), 'Name to greet. Optional, max length 256.', true)
->inject('response')
->action(function (string $name, Response $response) {
$response->send('Hello ' . $name);
$response->json([
'message' => "Hello {$name}!",
]);
});

$http = new Http(new Server('0.0.0.0', '80'), 'America/New_York');
$http = new Http(new Server('0.0.0.0', '80'), new \Utopia\DI\Container(), 'America/New_York');
$http->start();
8 changes: 8 additions & 0 deletions tests/e2e/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@
$response->send('Hello World!' . $param);
});

Http::get('/json')
->inject('response')
->param('name', 'World', new Text(256), 'Name to greet. Optional, max length 256.', true)
->action(function (Response $response, string $name) {
$response->addHeader('Content-Type', 'application/json');
$response->json(['message' => "Hello {$name}"]);
});

Http::error()
->inject('error')
->inject('response')
Expand Down