diff --git a/composer.json b/composer.json index 3a65ea9..9fd1102 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ ], "require": { "psr/http-message": "^2.0", - "nyholm/psr7": "^1.8" + "nyholm/psr7": "^1.8", + "nyholm/psr7-server": "^1.1" } } diff --git a/composer.lock b/composer.lock index fe54d41..0269a45 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b2ffab63d5bda6b880d677f709bf179b", + "content-hash": "9c15ad4fc717c578191a8cd9b9095bd0", "packages": [ { "name": "nyholm/psr7", @@ -84,6 +84,72 @@ ], "time": "2024-09-09T07:06:30+00:00" }, + { + "name": "nyholm/psr7-server", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/Nyholm/psr7-server.git", + "reference": "4335801d851f554ca43fa6e7d2602141538854dc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Nyholm/psr7-server/zipball/4335801d851f554ca43fa6e7d2602141538854dc", + "reference": "4335801d851f554ca43fa6e7d2602141538854dc", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "require-dev": { + "nyholm/nsa": "^1.1", + "nyholm/psr7": "^1.3", + "phpunit/phpunit": "^7.0 || ^8.5 || ^9.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Nyholm\\Psr7Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + }, + { + "name": "Martijn van der Ven", + "email": "martijn@vanderven.se" + } + ], + "description": "Helper classes to handle PSR-7 server requests", + "homepage": "http://tnyholm.se", + "keywords": [ + "psr-17", + "psr-7" + ], + "support": { + "issues": "https://github.com/Nyholm/psr7-server/issues", + "source": "https://github.com/Nyholm/psr7-server/tree/1.1.0" + }, + "funding": [ + { + "url": "https://github.com/Zegnat", + "type": "github" + }, + { + "url": "https://github.com/nyholm", + "type": "github" + } + ], + "time": "2023-11-08T09:30:43+00:00" + }, { "name": "psr/http-factory", "version": "1.1.0", diff --git a/public/index.php b/public/index.php index 267c54e..d49eac3 100644 --- a/public/index.php +++ b/public/index.php @@ -8,7 +8,15 @@ use Routes\Router; $router = new Router(); +$psr17Factory = new \Nyholm\Psr7\Factory\Psr17Factory(); -$uri = $_SERVER['REQUEST_URI']; +$creator = new \Nyholm\Psr7Server\ServerRequestCreator( + $psr17Factory, // ServerRequestFactory + $psr17Factory, // UriFactory + $psr17Factory, // UploadedFileFactory + $psr17Factory // StreamFactory +); -print_r($uri); +$serverRequest = $creator->fromGlobals(); + +print_r($serverRequest->getUri());