Questions tagged [slim-3]

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

slim-3
Filter by
Sorted by
Tagged with
0 votes
1 answer
86 views

Passing a Slim 3 Exception response to an Angular application

I’m creating an authentication system that uses Slim 3 PHP on the back-end and Angular on the front-end. So far I’ve managed to have it so a user can fill out a form on the frontend and send a post ...
SneakyShrike's user avatar
0 votes
2 answers
2k views

How to use basic authentication in slim php?

I am using slim framework to write my own API and everything is just fine but when I add the slim-basic-auth library to secure my API and test it .... I always get this error : Uncaught Error: ...
A.Ali's user avatar
  • 13
3 votes
1 answer
2k views

How should the domain object and data mapper interact within a service class for an auth system using MVC

I’m creating an authentication / login system using Slim 3 PHP on the back-end and Angular on the front-end and I’m trying to understand the ‘domain object’ and ‘data mapper’ part of a model layer ...
SneakyShrike's user avatar
0 votes
1 answer
268 views

Syntax Error while implementing LIMIT and OFFSET

I have following PHP serving me data by executing SQL on MARIADB. function getData ($countsql, $datasql, $page, $limit, $input, $response){ try{ $offset = ($page-1) * $limit; //calculate ...
Mercurial's user avatar
  • 3,795
0 votes
0 answers
347 views

How can I run my slim 3 controler action via cli?

I'm try to use https://github.com/pavlakis/slim-cli but I can't understand how to connect it. I add $app->add(new \pavlakis\cli\CliRequest()); in my Routes.php and I want to run \Controllers\...
hottern's user avatar
  • 13
0 votes
1 answer
55 views

Unable to create new routes in slim3 php

I am trying an example of slim3 PHP mico frameworks. I have two routes need to be included in index.php first is successfully added and when I am trying to add second one, I am facing a problem here ...
Asesha George's user avatar
2 votes
1 answer
2k views

Redirecting with a different HTTP method

I have an endpoint to update a given entity, and the response should be the updated entity. I hterefore tried the following, however, the redirect is another PUT request. How do I respond with a GET ...
user1032531's user avatar
  • 25.7k
0 votes
1 answer
365 views

Slim Test Error: Function name must be a string

I am setting up a PHP Slim 3 boilerplate project and I am trying to set up an environment for which I can run my tests. To do this, I created a set-up php class file that inherited the PHPUnit (v 7.5)...
Kennedy Osaze's user avatar
1 vote
0 answers
513 views

Asset versioning/Browser cache busting with Encore, Slim, and Twig

I'm using Symfony's Webpack Encore package to manage assets within a Slim 3 project with Twig templates. https://symfony.com/doc/current/frontend.html#webpack-encore I need to be able to utilize the ...
bigtunacan's user avatar
  • 4,913
2 votes
1 answer
1k views

Cannot load class with require_once when using namespace

I'm using Slim for develop a simple REST API, and I'm facing a weird problem. Essentially I configured the API to load all the classes using the autoloader via composer: "autoload": { "psr-4": { ...
sfarzoso's user avatar
  • 1,490
0 votes
1 answer
1k views

Slim3 Cannot use object of type Slim\Http\Response as array

I am having trouble with adding error output to the JWT middleware set up. I am getting this error: Cannot use object of type Slim\Http\Response as array I am using Slim 3 and the slim-jwt-auth ...
donfifty's user avatar
  • 352
3 votes
2 answers
3k views

How to read the response body when API error happen using curl?

I developed an API using Slim v3, when an exception is raised I have an ErrorHandler which return the following: public function __invoke(Request $request, Response $response, \Exception $exception) {...
sfarzoso's user avatar
  • 1,490
0 votes
0 answers
142 views

Always the same view content on slim framework with twig after save changes

I'm using Slim and Twig and I'm trying to change a view content, but it doesn't change after I saved the changes. This is the controller: <?php use \Psr\Http\Message\ServerRequestInterface as ...
af_12345's user avatar
0 votes
1 answer
483 views

How to secure a slim 3 application with user authentifcation

I'm quiet new to slim, but I want to give it a try. I have created an application, which uses twig as view rendering. A user should authenticate against a database (via a login form), before access ...
Urastor's user avatar
  • 91
3 votes
2 answers
3k views

Slim 3 framework - Passing data from middleware to controller - action args

I'm using a controller/middleware build with slim 3 and i want from the middleware attached to a group, to pass some data to the $args parameter in my controller - action. Here's some code: class ...
C Apetrei's user avatar
0 votes
1 answer
41 views

Slim3 how can I manage mixed content type errors

I need to set up a Slim application for html and json contents. I will have just one errorhandler and it is supposed to reply as json for json enpoints and html error page for html views. In the old ...
Tobia's user avatar
  • 9,299
1 vote
1 answer
1k views

How to log all Eloquent queries

I'm using Eloquent standalone inside Slim3 framework. I would like to log all DB queries from Eloquent, I see some implementation but what I'm missing is to log the query when it is made and without ...
Tobia's user avatar
  • 9,299
1 vote
1 answer
1k views

Slim Authentication middleware for all routes except someone

I would like to have a Slim middleware to check authentication on all requests but some specific ones (for example login page). I prepared the first AuthenticationMiddleware middleware to check all ...
Tobia's user avatar
  • 9,299
0 votes
1 answer
603 views

access Request object in route group - Slim Framework

I´m using Slim Framework and I need to access the Request object in a group so I can create objects and use them in the routes $app->group('/my-group', function (App $app) { $id = $app->...
handsome's user avatar
  • 2,325
1 vote
0 answers
81 views

Is there anyway to call dynamic object inside Slim middleware?

I'm having a pure php source then i integrate Slim 3 inside the source. In the index.php to init Slim app, i have required all class i have already defined and i also call to some member functions of ...
Steven Dang's user avatar
0 votes
1 answer
461 views

How to get params from any Uri in Slim 3 Framework?

I'm new to Slim 3 framework. I want to get the param such as api_key or token from any API URL to validate if the requested api_key is correct. (Any request API with any method sent to server will ...
Steven Dang's user avatar
-1 votes
2 answers
38 views

API doesn't allow text

I've just created a simple API for a CAD/MDT I'm working on, I've managed to get it to show the correct information when I do /citations/userid/1. This will then display all the correct values from ...
Kevin Gorman's user avatar
0 votes
1 answer
32 views

Slim3 use reference is wrong

I'm tring to prepare a simple empty application with Slim3 and composer. This is my front controller: <?php require '../vendor/autoload.php'; $config=[]; $config['displayErrorDetails'] =...
Tobia's user avatar
  • 9,299
0 votes
0 answers
483 views

Call to a member function addMessage() on null,

I am trying to add slim flash message to be accessed with my controller using Slim framework 3 & Twig, But I get the following error : Call to a member function addMessage() on null, Buzz\...
Vena's user avatar
  • 33
2 votes
1 answer
512 views

Respect Validation php slim custom messages

I've read the docs and I wonder if its possible to make custom messages based on rules AND attribute, for example I have the following code $casoValidator = Validator::attribute('nombre',Validator::...
JoseCarlosPB's user avatar
-1 votes
1 answer
224 views

Pass Data between route in Slim

I am new to slim and I want to pass Data between two routes (apps) $app->get('/answer', function (Request $request, Response $response) use($talk,$voiceName,$message){ // submit this data ...
Dani Evan Rubenstein's user avatar
0 votes
1 answer
2k views

Bundle JS and CSS for a PHP Web application?

I am building a website using PHP and Slim framework. I have about 12 Javascript files and 8 CSS files and am looking to bundle them in order to decrease the number of HTTP requests. I have come ...
Saish Sk's user avatar
0 votes
2 answers
298 views

Slim 2.x to 3.x upgrade - configureMode and getInstance replacement

I am working on upgrading Slim 2.x to 3.x to fix security findings. Currently in Slim 2 we are using configureMode to store environment specific database connections. The 3.0 upgrade guide only says ...
Zygo's user avatar
  • 15
1 vote
1 answer
245 views

CMS like wildcard routing with Slim 3

I'm working on a (very lightweight) CMS on Slim 3 for some projects I’m working on. I’m struggling with the routing. Maybe someone here can nudge me in the right direction. The admin is able to add ...
Chriss's user avatar
  • 37
0 votes
2 answers
99 views

Eloquent modify data before retuning them

I want to build up something like a middleware on Eloquent. When I make a request on my model "Event" I need to always parse the date value. Here is what I have: Event model: class Event extends ...
LUXS's user avatar
  • 343
0 votes
1 answer
282 views

How do I remove /public from the URL?

I am using Slim framework to build a website. How to I re-write the url using .htaccess ? This is what my .htaccess file looks like, any route is redirected to index page, I got this from the Slim ...
Saish Sk's user avatar
0 votes
1 answer
466 views

How to add Respect Validation on child Object which is Optional

In Slim3 framework's Respect Validation, I am trying to add validation on child object. $childObjValidationArr = array( 'param1' => v::regex("/^[A-Za-z0-9]{1}[A-Za-z0-9.$#-@]{1,19}$/"), '...
Anup B's user avatar
  • 87
0 votes
1 answer
941 views

Custom error handlers in Slim 3 not working

I want to override the default error handlers in Slim 3 and respond with JSON instead of the default HTML page. But I can't get it to work, my custom handlers are ignored completely and I can't figure ...
Emil Carlsson's user avatar
0 votes
0 answers
159 views

Slim-3 php framework shows page not found error even the url is correct?

Slim-3 php framework shows page not found error even the url is correct. I am writing webservice for android application in php using slim3 framework. few days before it was working fine.same code is ...
Imran Anwar's user avatar
0 votes
1 answer
199 views

Slim php csrf failed

I've got a controller action which output's CSV file using league/csv package. When I post the form the file can be downloaded but if the post request is posted again I'm getting csrf token failed ...
rameez.hashmi's user avatar
0 votes
2 answers
2k views

How to group by column name in Twig?

I am trying to group in for loop using Twig. I have found an extension for Twig which adds additional features to twig. Here is the link for that: twig-lambda. When I am trying to group by ...
Elvin Huseynov's user avatar
0 votes
1 answer
220 views

Slim framework and automated group routing

I would like to move all logic into controllers like this: index.php file: $app = new Slim\App(); $app->group('/api/v1', function (\Slim\App $app) { $app->group('/users', UsersController::...
step's user avatar
  • 2,292
0 votes
1 answer
1k views

PHP Slim - No Access-Control-Allow-Origin header is present on the requested resource

I'm new to Slim framework. I'm building a REST API and I'm having problems implementing CORS. First I went along with the example from the Slim cookbook: Then I used /tuupola/cors-middleware : I ...
yarex's user avatar
  • 65
0 votes
2 answers
84 views

Can not use '$query' in slim 3 with Laravel eloquent

I use slim 3 for microservice for that i install laravel eloquent and i write a laravel query like following use Illuminate\Database\Capsule\Manager as DB; DB::enableQueryLog(); $faqs = DB::table('...
Hariz Mohammed's user avatar
0 votes
1 answer
202 views

How create middleware group for route

Is it possible to create middleware groups for each route in slim3? I create a route, in the middleware.php file I set a list of middlewares and it turns out all the routes will go through this list, ...
Alexey's user avatar
  • 1
-1 votes
2 answers
255 views

Slim Api Using $settings $logger and $db in __construct from dependencies.php in a Model function

Good morning How Can I use $settings $logger and $db in __construct from the $container in dependencies.php in a Model function in a Slim Api? I have the following setup for my Slim framework Api: ...
j00ls's user avatar
  • 105
0 votes
1 answer
118 views

How to separate different routes in different directory with slim Framwork

I am having some issues setting up routes in my app in different directories. The app only loads one of the routes files. File Structure myapp |_public | |_vendor | |...
foliwe83's user avatar
  • 560
0 votes
1 answer
400 views

Question marks returned instead of Arabic characters ONLY when xampp servers are launched from within program

As the title says, question marks are returned only when I run mysqld.exe and httpd.exe from within my java program. However, when I run xampp.exe and start apache and mysql from the UI it works ...
hman_codes's user avatar
2 votes
2 answers
1k views

Slim 3 PHP - can't access values in settings.php from middleware.php

I have a midleware that checks for a valid signature on a JWT token for GET requests to private routes. In it, I need to supply my JWT secret which is stored in settings.php at ['settings']['jwt']['...
Daveh0's user avatar
  • 982
1 vote
3 answers
1k views

Slim Framework routes returns not found except "get" named ones

I use: slim-skeleton (Mr. Rob Allen's scaffold provided on github) Under /projects grouped routes, only "get" method routes work without any problem but with rest of all return page not found error. ...
bgul's user avatar
  • 146
0 votes
0 answers
201 views

How can I make request between two routes in Slim PHP?

I have one route with registration functionality: $app->post('/account/signup', function(\Slim\Http\Request $request, \Slim\Http\Response $response, $args) use($app) { //new record to database })...
erNesto's user avatar
1 vote
1 answer
178 views

Unknown "rootform" test rendering Form in PHP

I'm trying to get Symfony Forms (with Twig Bridge), Slim and Twig playing nicely together but can't see to do it with any success. From what I can see I have the form aspect of things working, in that ...
Crags's user avatar
  • 41
1 vote
2 answers
1k views

PHP - Structuring a Slim3 web application using MVC and understanding the role of the model

I’m trying to create an authentication system in php with the Slim3 framework along with the Twig template system, and for the database I’m using MySQL with PDO. I’m also trying to implement it using ...
SneakyShrike's user avatar
0 votes
0 answers
161 views

Slim 3 Framework download file not show download dialog

I try download file .png use Slim 3 with this code: $app->get('/api/download/content/image/{filename}', function($request, Slim\Http\Response $response, $args) { $file = __DIR__ . '/uploads/...
Rofie Sagara's user avatar
1 vote
0 answers
59 views

How to connect slim3 api endpoint to serve 3rd party php file

tldr I want to make an endpoint /tools/dbadmin to serve adminer file for database management. In slim 3 Question During slim 2 era, I simply used to put_file_content adminer file to an endpoint and ...
Abhinav Kulshreshtha's user avatar

1
2
3 4 5
9