Created
March 16, 2019 10:32
-
-
Save karenirenecano/b038ae328448c8cbbb81f48fd99e8faa to your computer and use it in GitHub Desktop.
Serverless PHP slim framework POST does not get posted data
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
src | |
| | |
|_public | |
| |_index.php | |
| | |
| | |
|_bref.php | |
the `src\bref.php` | |
` | |
<?php declare(strict_types=1); | |
include __DIR__.'/public/index.php'; | |
` | |
then the `public/index.php` has the classic slim routing with bref app | |
` | |
<?php | |
use Bref\Bridge\Slim\SlimAdapter; | |
use \Psr\Http\Message\ServerRequestInterface as Request; | |
use \Psr\Http\Message\ResponseInterface as Response; | |
require __DIR__ . '/../vendor/autoload.php'; | |
$app = new \Slim\App( | |
require __DIR__ . '/../config/settings.php' | |
); | |
... | |
/** | |
* Grouped api | |
*/ | |
$app->group('/api', function (\Slim\App $app) { | |
$app->post('/mail', function (Request $request, Response $response) { | |
$mail = new Service\Mail($request, $response); | |
return $mail->send(); | |
}); | |
}); | |
... | |
$bref = new \Bref\Application; | |
$bref->httpHandler(new SlimAdapter($app)); | |
$bref->run(); | |
` | |
the route `/api/mail` POST method is working on an apache server (traditional LAMP stack). | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Were you able to make this work?