{"id":21762323,"url":"https://github.com/dannyyassine/ivory","last_synced_at":"2026-06-23T03:31:15.781Z","repository":{"id":198112797,"uuid":"700103709","full_name":"dannyYassine/ivory","owner":"dannyYassine","description":"Powered by Open Swoole: high-performance http micro PHP library","archived":false,"fork":false,"pushed_at":"2023-10-12T02:31:08.000Z","size":350,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-21T04:42:09.525Z","etag":null,"topics":["http","lib","library","openswoole","php","swoole"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dannyYassine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-04T00:28:50.000Z","updated_at":"2023-10-09T17:55:24.000Z","dependencies_parsed_at":"2023-10-12T10:12:55.146Z","dependency_job_id":null,"html_url":"https://github.com/dannyYassine/ivory","commit_stats":null,"previous_names":["dannyyassine/ivory"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dannyYassine/ivory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dannyYassine%2Fivory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dannyYassine%2Fivory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dannyYassine%2Fivory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dannyYassine%2Fivory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dannyYassine","download_url":"https://codeload.github.com/dannyYassine/ivory/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dannyYassine%2Fivory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34674702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-23T02:00:07.161Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","lib","library","openswoole","php","swoole"],"created_at":"2024-11-26T12:11:44.886Z","updated_at":"2026-06-23T03:31:15.766Z","avatar_url":"https://github.com/dannyYassine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg height=\"auto\" style=\"width: 420px; object-fit: contain;\" src=\"https://github.com/dannyYassine/ivory/blob/main/logo-large.png?raw=true\" alt=\"logo.png\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\nPowered by \u003ca href=\"https://openswoole.com/\" target=\"_blank\"\u003eOpen Swoole\u003c/a\u003e: high-performance http micro PHP library\n\u003c/p\u003e\n\n```php\n$app = new Ivory\\Application();\n\n$app-\u003esetHost('0.0.0.0')-\u003esetPort(8000);\n\n$app-\u003estart();\n\n// Ivory http server listening on http://0.0.0.0:8000\n```\n\n## Routing:\n```php\n$app-\u003eget('/', HomeController::class);\n```\n\n### Group routes\n```php\n$app-\u003egroup('/api', function (Router $router) {\n  $router-\u003eget('/name', GetController::class);\n  $router-\u003epost('/name', SaveController::class);\n  $router-\u003eput('/name', UpdateController::class);\n  $router-\u003edelete('/name', DeleteController::class);\n});\n```\n\n### Dynamic routes\n```php\n$app-\u003eget('/api/weather/city/:city', GetWeatherController::class);\n```\n\n## Use case driven controllers:\n```php\nclass HomeController {\n  public function execute(Request $request): string {\n    return 'This is my response';\n  }\n}\n```\n\n### Customize the response\n```php\nclass GetUserController {\n  public function execute(Request $request, Response $response): array {\n    $response-\u003eheader(\"Content-Type\", \"application/json\");\n\n    return [\n      'user' =\u003e User::first()\n    ];\n  }\n}\n```\n\n## Bind services/controllers to the D.I. container:\n```php\n$app-\u003ebind(Service::class, function () {\n  return new Service();\n});\n\n$app-\u003ebind(HomeController::class, function (Container $c) {\n  return new HomeController(\n    service: $c-\u003eget(GenerateNameService::class)\n  );\n});\n```\n\n### Dependencies will be injected to the constructor:\n```php\nclass HomeController {\n  public function __construct(protected Service $service) {\n    //\n  }\n}\n```\n\n## Global middlewares\n```php\n// before the request is handled\n$app-\u003eaddPreGlobalMiddleware(CheckIPMiddleware::class);\n\n// after the request is handled\n$app-\u003eaddPostGlobalMiddleware(LogRequestMiddleware::class);\n```\n\n## Controller middlewares\n```php\n// third argument in router definition\n$app-\u003eget('/name', NameController::class, [NameMiddleware::class]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyyassine%2Fivory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdannyyassine%2Fivory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyyassine%2Fivory/lists"}