viloveul / http
Http Component of Viloveul, Implementation PSR HTTP Message with Zend Diactoros
Installs: 168
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/viloveul/http
Requires
- php: ~7.0
- psr/http-message: ^1.0
- zendframework/zend-diactoros: 2.1.*
Requires (Dev)
- symfony/var-dumper: ~3.4|~4.0
README
make sure your php version > 7.0
composer require viloveul/http
HOW
require __DIR__ . '/vendor/autoload.php'; // e.x : http://yourdomain.com/path/to/something?param1=data1¶m2=data2 $request = Viloveul\Http\Server\RequestFactory::fromGlobals(); $param1 = $request->getQuery('param1', 'nothing'); $param2 = $request->getQuery('param2', 'nothing'); $param3 = $request->getQuery('param3', 'nothing'); var_dump($param1, $param2, $param3); // OR you can assign to object class SampleParam implements Viloveul\Http\Contracts\ServerRequestAssignment { protected $attributes = []; public function setAttributes(array $attributes): void { $this->attributes = $attributes; } public function getAttributes(): array { return $this->attributes; } } $data = $request->loadQueryTo(new SampleParam); var_dump($data);
Available Methods
- getQuery(key)
- getPost(key)
- getServer(key)
- loadQueryTo(object)
- loadPostTo(object)
- loadServerTo(object)