Zend\Diactoros\Response\Serializer::fromString PHP Method

fromString() public static method

Deserialize a response string to a response instance.
public static fromString ( string $message ) : Response
$message string
return Zend\Diactoros\Response
    public static function fromString($message)
    {
        $stream = new Stream('php://temp', 'wb+');
        $stream->write($message);
        return static::fromStream($stream);
    }

Usage Example

Example #1
0
 /**
  * @param string $fileName
  * @param RequestInterface $request
  * @param string $type
  * @return ResponseInterface
  */
 private function executePhpFile($fileName, RequestInterface $request, $type)
 {
     $process = $this->getProcess($fileName, $request);
     $process->start();
     $this->eventDispatcher->dispatch(new CgiExecuteEvent(sprintf('cgi.verify.%s.executing', $type), $request));
     $process->wait();
     if (!$process->isSuccessful()) {
         throw CodeExecutionException::fromProcess($process);
     }
     //if no status line, pre-pend 200 OK
     $output = $process->getOutput();
     if (!preg_match('/^HTTP\\/([1-9]\\d*\\.\\d) ([1-5]\\d{2})(\\s+(.+))?\\r\\n/', $output)) {
         $output = "HTTP/1.0 200 OK\r\n" . $output;
     }
     return ResponseSerializer::fromString($output);
 }
All Usage Examples Of Zend\Diactoros\Response\Serializer::fromString