Created
September 19, 2019 16:31
-
-
Save kemalyen/fce48176c12dd544013cd8ed33ce231a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Delegate static file requests back to the PHP built-in webserver | |
if (PHP_SAPI === 'cli-server' && $_SERVER['SCRIPT_FILENAME'] !== __FILE__) { | |
return false; | |
} | |
chdir(dirname(__DIR__)); | |
require 'vendor/autoload.php'; | |
$request = Zend\Diactoros\ServerRequestFactory::fromGlobals(); | |
$response = new Zend\Diactoros\Response(); | |
// Write to the response body: | |
$response->getBody()->write("some content\n"); | |
// Multiple calls to write() append: | |
$response->getBody()->write("more content\n"); // now "some content\nmore content\n" | |
// Add headers | |
// Note: headers do not need to be added before data is written to the body! | |
$response = $response | |
->withHeader('Content-Type', 'text/html') | |
->withAddedHeader('X-Show-Something', 'something'); | |
$emitter = new Zend\Diactoros\Response\SapiEmitter(); | |
return $emitter->emit($response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment