Skip to content

Instantly share code, notes, and snippets.

@karenirenecano
Created March 16, 2019 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karenirenecano/b038ae328448c8cbbb81f48fd99e8faa to your computer and use it in GitHub Desktop.
Save karenirenecano/b038ae328448c8cbbb81f48fd99e8faa to your computer and use it in GitHub Desktop.
Serverless PHP slim framework POST does not get posted data
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).
@maverick108
Copy link

Hi,
Were you able to make this work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment