Questions tagged [slim]

Slim for PHP is a RESTful micro framework for PHP 5 inspired by Sinatra.

  • Slim 3 requires PHP 5.5.0 or newer.

Resources

Features

  • Router Slim uses the FastRoute router and maps route callbacks to specific HTTP request methods and URIs. It supports route segment parameters and pattern matching.

  • Middleware Build your application with custom concentric middleware to tweak the HTTP request and response objects before and after your Slim app runs.

  • HTTP Slim has easy-to-use PSR-7 request and response abstractions that let you inspect and manipulate HTTP messages' method, status, URI, headers, cookies, and body.

Related tags


For the Ruby template engine use instead.

2828 questions
94
votes
9 answers

enable cors in .htaccess

I have created a basic RESTful service with the SLIM PHP framework and now I'm trying to wire it up so that I can access the service from an Angular.js project. I have read that Angular supports CORS out of the box and all I needed to do was add…
Devin Crossman
  • 7,454
  • 11
  • 64
  • 102
69
votes
12 answers

Axios - How to read JSON response?

Axios 0.17.1 .then(function (response) { console.log(response); //console.log(response.status); //It is an error -> SyntaxError: Unexpected token u in JSON at position 0 …
Mahesh
  • 1,503
  • 3
  • 22
  • 33
67
votes
10 answers

Slim PHP and GET Parameters

I'm using Slim PHP as a framework for a RESTful API. How do I grab GET params from the URL in Slim PHP? For example, if I wanted to use the following: http://api.example.com/dataset/schools?zip=99999&radius=5
Eric Arenson
  • 797
  • 1
  • 6
  • 11
51
votes
6 answers

Slim Framework for beginners

How does anybody learn how to use this system? I can't seem to find any tutorials or books or anything on how to use this program. Yes their website briefly explains a few things but there is no clarification or anything. Google has failed me. Can…
Steve Whitmore
  • 903
  • 1
  • 9
  • 22
41
votes
4 answers

Slim 3 - how to get all get/ put/ post variables?

How I can get all get/ put/ post variables like in Slim 2 for Slim 3? Slim 2, $allGetVars = $app->request->get(); $allPutVars = $app->request->put(); $allPostVars = $app->request->post(); How can I do that in Slim 3? And, for example,…
Run
  • 54,938
  • 169
  • 450
  • 748
31
votes
17 answers

Slim JSON Outputs

I am using the Slim framework with PHP to create a RESTful API for my app. However, I assumed that the framework would have some way of creating easier JSON outputs rather than just exit($jsonEncodedVariable);. Am I missing something in the…
max_
  • 24,076
  • 39
  • 122
  • 211
29
votes
1 answer

Nginx location configuration (subfolders)

lets say I've a path like: /var/www/myside/ that path contains two folders... let's say /static and /manage I'd like to configure nginx to have an access to: /static folder on / (eg. http://example.org/) this folder has some .html files. /manage…
Nubzor
  • 522
  • 1
  • 5
  • 14
27
votes
8 answers

Slim Framework always return 404 Error

These days i'm using Slim Framework as my simplest tool to develop the php web api. Using these two articles: Coenraets CodingThis I follow some of the steps from there. Downloading the Slim Framework, putting the correct directory & files.…
gumuruh
  • 2,544
  • 4
  • 33
  • 56
27
votes
4 answers

Slim - How to send response with "Content-Type: application/json" header?

I have this simple REST api, done in Slim, true, …
branquito
  • 3,864
  • 5
  • 35
  • 60
23
votes
1 answer

Why is JWT::decode() returning { "status": "\"kid\" empty, unable to lookup correct key" }

My first ever Stack Overflow Question - here it goes! I've encoded a Firebase JWT token to authenticate a 'buyer' in my PHP Slim API. It encodes correctly and generates a JWT token in Postman, Postman JWT encoding but when I try to use the JWT for…
Dwags317
  • 330
  • 1
  • 2
  • 8
23
votes
2 answers

RESTful API Doc using SLIM and SWAGGER?

I am new to this stuff but I love it. I made a little REST Api using the Slim Framework. Now I would like to have an ongoing documentation about it. I think swagger is the right choice but I have not found out yet how to integrate it ? Cheers &…
user2942586
  • 333
  • 1
  • 2
  • 12
22
votes
9 answers

how to use slim redirect

I have a problem. I am using slim and I have route for my main page: $app->get('/', function() use ($app) { ... In one of my controllers I want to redirect to the main page, so I write $app->response->redirect('/', 303); But instead of…
dKab
  • 2,658
  • 5
  • 20
  • 35
21
votes
3 answers

Eloquent join using "USING" clause with N query

I'm using Slim Framework with Illuminate Database. I want to make JOIN query with USING clause. Let's say given Sakila database. Diagram: How to make join with USING clause (not ON) in eloquent model? SELECT film_id,title,first_name,last_name FROM…
Egy Mohammad Erdin
  • 3,402
  • 6
  • 33
  • 57
21
votes
1 answer

How do I write unit tests for a REST API built in Slim Framework?

I have an API built in Slim like this: $app->group('/'.$endpoint, function () use ($app, $endpoint) { $handler = Api\Rest\Handlers\Factory::load($endpoint); if (is_null($handler)) { throw new \Exception('No REST…
bcmcfc
  • 25,966
  • 29
  • 109
  • 181
20
votes
4 answers

Intermittent PHP Abstract Class Error

I've been fighting this for a bit, and can't figure it out, maybe someone else has or maybe there's a deeper issue here with Slim, PHP, Apache etc. After working just fine for hours, my Slim install will start giving this on all routes: Fatal…
Will Shaver
  • 12,471
  • 5
  • 49
  • 64
1
2 3
99 100