$slice = new \PHPixie\Slice(); $http = new \PHPixie\HTTP($slice);
// $request = $http->request(); // // PSR-7 ServerRequestInterface $request = $http->request($serverRequest); //$_GET $query = $request->query(); //$_POST $query = $request->data(); // // $query = $request->attributes(); //$_GET['pixie'] $query->get('pixie'); // $query->get('pixie', 'Trixie'); // $query->getRequired('pixie'); //$_GET['user']['name']; $query->get('user.name'); // $userData = $query->slice('user'); $userData->get('name'); // $userData // \PHPixie\Slice\Data // HTTP // - // $request->server()->get('http_host'); // $request->headers()->get('host'); $request->headers()->getRequired('host'); // $request->headers()->getLines('accept'); // PSR-7 $uploadedFile = $request->uploads()->get('file'); $uploadedFile->move('/images/fairy.png'); // URI $uri = $request->uri(); $path = $uri->getPath(); // - // ServerRequestInterface $serverRequest = $request->serverRequest();
$responses = $http->responses(); // $response = $responses->string('hello world'); //JSON $responses->json(array('name' => 'Pixie')); // $responses->redirect('http://phpixie.com/'); // $responses->streamFile('pixie.png'); // // CSV, TXT $responses->download('name.txt', 'text/plain', 'Trixie'); // $responses->downloadFile('pixie.png', 'image.png', 'images/fairy.png'); // $response->setStatus('404', 'Not Found'); // $response->setStatus('404'); // $response->headers->set('Content-Type', 'text/csv'); // PSR-7 ResponseInterface $response->asResponseMessage(); // $http->output($response);
// $context = $http->context($request); // $cookies = $context->cookies(); $session = $context->session(); $cookies->set('lang', 'en'); $session->getRequired('user_id'); // // $http->output($response, $context); $response->asResponseMessage($context);
Source: https://habr.com/ru/post/256639/
All Articles