Quantcast
Channel: Slim Framework – Rob Allen's DevNotes
Browsing latest articles
Browse All 38 View Live

Replacing a built-in PHP function when testing a component

Recently I needed to test part of Slim that uses the built-in PHP functions header() and headers_sent(). To do this, I took advantage of PHP's namespace resolution rules where it will find a function...

View Article


Route specific configuration in Slim

A friend emailed me recently asking about route specific configuration in Slim. He wants to be able to set properties when creating the route that he can pick up when the route is matched. The way to...

View Article


Slim 4 Cyclomatic Complexity

There's not much wrong with Slim 3; lots of people are using it very successfully producing APIs and websites of all kinds. For Slim 4 the main goals have been to support PSR-15, make it easier to use...

View Article

A first look at Slim 4

With Slim 4 we have continued the tradition of allowing you to use the framework in the way that best fits you and your project. You can create a Slim application entirely in a single file suitable for...

View Article

Image may be NSFW.
Clik here to view.

Receiving input into a Slim 4 application

A Slim 4 (and Slim 3) application receives data from three places: Any query parameters on the URL (the key-value pairs after the ?) The HTTP message's body (usually for POST and PUT) messages...

View Article


Slim4-empty: minimal Slim 4 starting point

To simplify creating a new Slim 4 project, I've created slim4-empty which does this for me. To use it: $ composer create-project akrabat/slim4-empty my-new-project and you're done! The my-new-project...

View Article

Running Slim 4 in a subdirectory

If you want to run Slim 4 in a subdirectory of your website, then you have a few things you need to do. Let's consider the situation: Your main website is in the directory /var/www/html and is accessed...

View Article

Dependency Injection in Slim 4

In contrast with Slim 2 and Slim 3, Slim 4 does not ship with a DI container, but instead, supports any PSR-11 compatibly DI container that you provide. This is part of Slim 4's commitment to...

View Article


Image may be NSFW.
Clik here to view.

Custom error rendering in Slim 4

One of the nice things about Slim 4 is that it's easier to customise the HTML generated on error without having to worry about the rest of the error handling mechanism. This is because we have...

View Article


Setting HTTP status code based on Exception in Slim 4

One thing that's quite convenient is to be able to throw an exception with a valid HTTP code set and have that code sent to the client. For example, you may have: throw new \RuntimeException("Not...

View Article
Browsing latest articles
Browse All 38 View Live