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
2
votes
2 answers

Slim 3 - replacement for isPost()?

In Slim 2, I would do this, $app->map('/login', function () use ($app) { // Test for Post & make a cheap security check, to get avoid from bots if ($app->request()->isPost() && sizeof($app->request()->post()) >= 2) { // } …
Run
  • 54,938
  • 169
  • 450
  • 748
1
vote
1 answer

How to call an API endpoint in Slim Framework v3 from within a route?

I'm using the PHP Slim Framework v3 to make a web app and the routes I have are all typically divided into either a frontend route or an API endpoint. I have a frontend route where I want to call an API endpoint to get data to display. For…
dokgu
  • 4,957
  • 3
  • 39
  • 77
1
vote
2 answers

How to inset data with eloquent models in slim out of the laravel?

Hi im new to the slim framework so i want to know that how to inset data to the table of users with eloquent database ? model namespace App\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { protected $table =…
Thiru
  • 17
  • 4
1
vote
1 answer

Add value to route before in slim framework

Hi Folks i upgrading my slim framework from slim 2 to slim 4 for older project for one route i added the one value before route using slim 2 slim.before in index.php example code: $app->hook('slim.before', function () use ($app) { $env =…
Dinesh s
  • 313
  • 4
  • 19
1
vote
1 answer

Twig function/filter with no input?

I'm using Slim 3 and Slim Twig-View. I want to add a Twig function (or filter, not sure what is the difference?) which generates a random string, and doesn't take any input. I was able to add a filter like this: $twig->getEnvironment()->addFilter( …
Magnus
  • 17,157
  • 19
  • 104
  • 189
1
vote
1 answer

How to create a route that ends with .html in Slim Framework PHP

I have used Slim Framework several times without any problem but now I'm trying to set a route to match URL that ends with .html and render a certain view, but the framework return a 404 Not Found error, the route is ignored and it seems to me that…
Jomosen
  • 21
  • 2
1
vote
1 answer

Log PHP exceptions and Errors to Database table PHP Slim 3

So I am trying to find the best way to get PHP SLIM 3 to log PHP exceptions and errors to a Database table instead of a log. whats the best way to accomplish this? So far in the documentation recommends this. Dependency: $app = new \Slim\App(); $c…
user13532287
1
vote
1 answer

SlimPHP route with empty parameter fails

I have a route like this /product/update/{productId}/part/{partId} If I try to call that with one or more empty parameters, it fails and gives me a HTTP 404 Not Found, for example https://localhost/product/update//part/xyz123 I can't make them…
Magnus
  • 17,157
  • 19
  • 104
  • 189
1
vote
0 answers

Slim Framework to log errors to database

I am trying to figure out how to php stack trace errors (PDOEXception errors) but get the message to log into a database instead of to a log file. How can I best accomplish this?
user12438439
1
vote
1 answer

How can i set multiple Header Keys with Slim Framework 3

I am using the below sample code to return data to the browser $response->write($image); return $response->withHeader('Content-Type', 'image/jpeg'); which works fine but how would i go about it if i wanted to also return Content-Length ? the only…
NoSoup4you
  • 640
  • 1
  • 10
  • 34
1
vote
2 answers

Proper redirection to avoid www/non-www pages being counted as duplicates

Site audits (Semrush, Seobility) point out that one of our biggest issues is duplicate content, stating that "This website uses URLs with www and non-www subdomain. This may cause duplicate content and bad links to your website." So, basically…
cesarcarlos
  • 1,271
  • 1
  • 13
  • 33
1
vote
2 answers

How to fix Slim 3 PUT,DELETE request not working

I am trying to implement DELETE and PUT request but I'm having an error. below is my code $app->group('/departments', function () { $this->put('/{id}', DepartmentController::class . ':update')->setName('department.update'); …
pal3
  • 241
  • 1
  • 2
  • 13
1
vote
1 answer

Redirect with HTTP 403

I'm using Slim PHP and want to redirect the user to /login if they are not logged in but try to access a page that requires a user to be logged in. When searching for how to build my middleware, I find variations of this code all over the…
Magnus
  • 17,157
  • 19
  • 104
  • 189
1
vote
3 answers

PHP Slim-3: How to redirect internally to another route

I have a generic route like below - $app->map(['GET', 'POST'], "/", function (\Slim\Http\Request $request, \Slim\Http\Response $response) use ($app) { // Some random version 1 processing here ... } And I have a v2 version of the same like…
ArunKolhapur
  • 5,805
  • 4
  • 18
  • 31
1
vote
2 answers

Retrofit response return null in onResponse function (single JSON object)

I'm try to get response from retrofit API after register the user. I get null from response.body() function Register URL: https://apitest10101.000webhostapp.com/alaa-apii/public/createuser (Method POST) The API return single object JSON like { …
SWAT 10101
  • 127
  • 3
  • 16