Questions tagged [slim-3]

Slim 3 is the successor to Slim 2, a micro framework for PHP.

Resources

Related tags


For the Ruby template engine use instead.

421 questions
0
votes
2 answers

Cannot retrieve all request headers using PHP slim framework

I'm using PHP slim framework for a personal project. For some reason, the PSR implementation of Request in Slim apparently is filtering some headers. I am trying to set a custom CSRF token and it is not available via $request->getHeaders(). Here's…
Jose Cifuentes
  • 596
  • 6
  • 21
0
votes
1 answer

Slim 3 - how add or-option into the route?

How can I have or-option in the Slim 3 routes? For instance, this is what I do currently: // Home page. $app->get('/', function (Request $request, Response $response, array $args) { // Get the application settings. $settings =…
Run
  • 54,938
  • 169
  • 450
  • 748
0
votes
1 answer

how to adding error handler in slim3 middleware

I started a project with slim3 framework. In my project I wrote a route group called admin for administrators. $app->group('/admin', function () use ($app) { $app->add( new AdminMiddleWare() ); $app->get('/books/{id}', function ($request,…
B. Azizan
  • 93
  • 1
  • 4
  • 12
0
votes
1 answer

Swagger.io Slim Framework POST errors

I used Swagger to generate a Slim framework for a server. Without editing anything, I am testing the basic functions. I have one located at /user/login. Here is the script I have for it: $app = new Slim\App(); $app->POST('/user/login',…
Brian Logan
  • 812
  • 2
  • 6
  • 20
0
votes
1 answer

PHP setting variable inside function's function

I need advice with setting variables. Im using Slim Framework. Ive got few classes. MailboxManager.php public function getMailById($id) { /* @var $sql PDOStatement */ $sql = $this->database->prepare("SELECT * FROM appmail_mails…
0
votes
1 answer

return $res->withStatus(401) in SlimFramework3 not appearing to work?

So I've done quite a bit of digging and can only seem to come up with information on SlimFramework 2, nothing so much on 3. My issue is this: return $res->withStatus(401)->withHeader('Content-type','application/json')->write(json_encode(array( …
0
votes
1 answer

Making server to server request to Google Calendar API

I am building a SPA using vue.js which has a PHP backend server (slim framework 3). These are two separate projects, leave on two different servers and the backend has no front end at all. SPA (vue.js) makes requests to backend via ajax. Now I…
Optimus
  • 1,703
  • 4
  • 22
  • 41
0
votes
1 answer

SwiftMailer 's setFrom not working with variable

I'm trying to send mail for a contact form locally by swiftmailer and gmail. I've checked every line and I know the problem is 'setFrom' . $app->post('/contact', function ($request, $response, $args){ $body = $this->request->getParsedBody(); $name…
Niloofar
  • 117
  • 1
  • 1
  • 13
0
votes
1 answer

Get param in Routing - Slim Framework 3

How can I get the param in this case? $this->get('/{id}', function($request, $response, $args) { return $response->withJson($this->get('singleSelect')); }); $this->appContainer['singleSelect'] = function ($id) { return…
0
votes
1 answer

How to view files sent through x-sendfile as GET response

I am using Slim Framework 3. Here's my code: .... $response = $response->withStatus(200) ->withHeader('X-Sendfile', $path) ->withHeader('Content-Type', $contentType) …
Samar Rizvi
  • 300
  • 1
  • 9
0
votes
1 answer

Create routes with controllers in Slim 3 like in Laravel 5

With the PHP framework Slim 3 in Routes, I did this: // In routes : $app->get('article/{id}-{slug}', function ($request, $response, $args) { $class = new Site\ArticleController($args); $class->show(); }); // In controllers : public function…
stephweb
  • 125
  • 2
  • 16
0
votes
1 answer

Slim Framework DB Service Exception Handling

I'm upgrading to slim v3. How should I use a database connection? I'm thinking about a service injected with pimple: DBConnection final class DBConnection { private $db; public function __construct() { try { // Code to…
Jumpa
  • 4,319
  • 11
  • 52
  • 100
-1
votes
1 answer

Controller not found in slim 3

I am new to slim,so please bear with me. I have project structure like \slim   \public     index.php        \src     \controllers \reports        BillingReportController.php \routes router.php \config …
-1
votes
1 answer

How to simplify if else with four different conditions

How can I simplifyy this code of mine?
ghabriel
  • 123
  • 9
-1
votes
1 answer

Organize Slim 3 API routes logic into functions

I would like structure the API in order to separate both the routing organization from actions in separate files. The current code does not return any errors, but the parameters are not collected correctly. Is there a simple way to organize into…
Qu4k3
  • 185
  • 3
  • 16