-
-
Save ardani/85fea58d7280560864df to your computer and use it in GitHub Desktop.
This file contains 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 | |
// Obviously, you would build up the request somewhere other than a route... | |
Route::get('/api', function() | |
{ | |
$client = new \GuzzleHttp\Client(); | |
$response = $client->get('http://path/to/api'); | |
return $response->getBody(); | |
}); | |
// Visiting '/api' would return "Hello World" from Lumen! |
This file contains 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 | |
$app->get('/text', function() | |
{ | |
return 'Hello World'; | |
}); | |
// You may need to enable CORS header if Laravel and Lumen are on separate servers! | |
$app->get('/json', function() use ($app) | |
{ | |
return response()->json([ | |
"foo" => 'bar' | |
]) | |
->header('Access-Control-Allow-Origin', '*'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment