Responses


Strings and Arrays

All routes and controllers should return a response to be sent back to the user's browser. Shadow provides several different ways to return responses. The most basic response is returning a string from a route or controller. The framework will automatically convert the string into a full HTTP response:

$router->get('/', function() {
    return 'Hello world';
});

In addition to returning strings from your routes and controllers, you may also return arrays. The framework will automatically convert the array into a JSON response:

$router->get('/', function() {
    return json_encode([1,2,3]);
});