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
1 answer

Get Route parameter from group route in SLIM 3 PHP

I am having issue getting the group route parameter in middleware here's what i am doing I am using [PHP - SLIM 3 Framework] route.php $app->group('/{lang}', function() use ($container){ //routes ... (ignore the other routes) })->add(new…
Abdul Rafay
  • 312
  • 6
  • 17
0
votes
1 answer

Doctrine 2 Getting 0 Results From findBy Query

Please note the following code below. This is a snippet from inside a function. global $entityManager; $username = $request->getParam('username'); $password = $request->getParam('password'); I double checked above and its getting this…
Joseph Astrahan
  • 8,659
  • 12
  • 83
  • 154
0
votes
1 answer

Slim 3 how to save JWT Token on local storage and use it in my routes for authentication

I want to implement jwt authentication for slim app, i followed tuupora's PRS7 jwt authentication middleware and its working fine when i use Postman because there are options to use header as "Authorization: Bearer tokenString" as here bellow when i…
frontendkiller
  • 125
  • 2
  • 13
0
votes
1 answer

slim Guzzle to psr http. for slim PhpRenderer view

$client = new \GuzzleHttp\Client(); $res = $client->request('GET', 'http://127.0.0.1/slim_project/getall', array( 'headers' => array( 'Authorization' => "Bearer fghfghfgh-sdfsdfs-sdfsdf}", …
Mahabub
  • 51
  • 4
0
votes
1 answer

Slim 3 - Unable to redirect to route with GET parameters from a ajax post request

I am using ajax post request to send data to my database using Slim 3. All the data gets posted and inserts into my database correctly but it will not redirect to the GET path. Ajax Post request code jQuery(function() { …
John
  • 111
  • 10
0
votes
0 answers

$response->withRedirect Does not show data that has been pass to the slim twig template engine

I am trying to get the data($errors) from the Array I pass into my slim\twig template using $response->withRedirect($this->router->pathFor($event->getRoute(),$errors )), but when I do a twig {{dump()}} i get null, However if I do "return…
Newbie2016
  • 517
  • 3
  • 6
  • 11
0
votes
1 answer

How to allow dots in Slim 3 or nikic/FastRoute parameters?

I am using Slim 3, which uses nikic/FastRoute, and am having trouble with an endpoint like so: $app->get('/count/{url}', function ($request, $response) use ($curl) { $controller = new Proximate\Controller\CountUrl($request, $response); …
halfer
  • 19,824
  • 17
  • 99
  • 186
0
votes
1 answer

There is a way to execute a Middleware after controller using withAttribute in the request? (slim 3)

I have to validate some attributes to the files , convert them to png and move them to amazon S3 service , but i need to move the file to the bucket only if the validation in controller is successful, the customer requirement is to use a middle ware…
0
votes
1 answer

Why does adding an extra middleware to slim 3 blocking jwt authentication with cors

I am having a problem with adding some custom middleware to a slim 3 project that is using tuupola/cors and slim-jwt-auth with the jwt token stored in the header as bearer for authentication. Everything is working well. When an ajax request is made…
Finglish
  • 9,692
  • 14
  • 70
  • 114
0
votes
1 answer

Change route files based upon URI path in Slim 3

Ok so I have 4 folders all which have their own route.php. So I would like to require the path to each folder based upon the uri path. So for example, if my website path is www.example.com/user then the Slim framework would require the path to…
Marcus Lee
  • 125
  • 1
  • 1
  • 7
0
votes
1 answer

How to redirect and store data for the request after the redirect

I am trying to redirect the user to the login page with errors and a flash message. Currently I'm doing this: return $this->container->view->render($response,'admin/partials/login.twig',['errorss'=>$errors]); But I want to redirect to the login…
ryan
  • 81
  • 8
0
votes
1 answer

Access $this inside a route in doesn't work "Using $this when not in object context"

I'm trying to use $this inside a function of a route, when I'm doing this, it gives me the following error: Using $this when not in object context Here's the code: function api($request, $response) { $response->write('REST API v1'); …
JackTheKnife
  • 3,795
  • 8
  • 57
  • 117
0
votes
1 answer

how to set a property in Slim 3

I am trying to add a property in Slim 3 container, but when I var dump it shows me "Notice: Undefined property: Slim\App::$user". I know in Slim 2 it is: $app->container->set('user',function(){ return new User; }); var_dump($app->user); This…
Newbie2016
  • 517
  • 3
  • 6
  • 11
0
votes
2 answers

Slim 3 - how to use or-operator in the route?

How can I do 'or' in the route? for instance, /about and /fr/about are pointing to the same objects/classes/methods. So instead of: $app->get('/{url:[a-zA-Z0-9\-]+}', function (Request $request, Response $response, array $args) { // same…
Run
  • 54,938
  • 169
  • 450
  • 748
0
votes
1 answer

Optional parameters in url - Slim 3

I have a pretty straightforward question. I am using Slim 3 to build a RESTfull api. How come this works: $app->get('/news[/{params:.*}]', function ($request, $response, $args) { $params = explode('/', $request->getAttribute('params')); …
user5156016