<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Slim on seth-shi</title><link>https://sethix.com/tags/slim/</link><description>Recent content in Slim on seth-shi</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Wed, 04 Dec 2019 17:21:20 +0800</lastBuildDate><atom:link href="https://sethix.com/tags/slim/index.xml" rel="self" type="application/rss+xml"/><item><title>Fake Requests in Slim for Your HTTP Testing Needs</title><link>https://sethix.com/posts/2019120417/</link><pubDate>Wed, 04 Dec 2019 17:21:20 +0800</pubDate><guid>https://sethix.com/posts/2019120417/</guid><description>When needing HTTP testing in code, Laravel has built-in functionality for this. With Slim, we have to build our own solution. After searching online for examples and finding limited resources, I decided to examine Laravel&amp;rsquo;s source code for inspiration. Discovered that the core idea is to mock a Request object and execute it to get response results. Implemented this approach in Slim framework accordingly. Setting Up Test Files Add autoload configuration in composer.</description></item><item><title>Using Middleware for Request Caching in Slim4</title><link>https://sethix.com/posts/2019112812/</link><pubDate>Thu, 28 Nov 2019 12:39:39 +0800</pubDate><guid>https://sethix.com/posts/2019112812/</guid><description>When developing web pages or API interfaces, we often encounter the following scenario:
A request is processed by querying the database and returning transformed data Some pages/interfaces with infrequent data changes (e.g. homepage) may experience performance issues under high traffic Solution: Cache processed content in storage like Redis before returning the response Subsequent requests first check the cache - return immediately if valid If cache expires, repeat steps [3-4] Here&amp;rsquo;s an implementation in Slim4 framework:</description></item><item><title>Slim - PHP - Laravel Performance Test</title><link>https://sethix.com/posts/2019112515/</link><pubDate>Mon, 25 Nov 2019 15:32:13 +0800</pubDate><guid>https://sethix.com/posts/2019112515/</guid><description>Test Environment Local Configuration (Win 10 i7-8565U 16G)(Nginx 1.15.11)(MySQL 5.5.62) Cloud Server (1 Core 2G)(Nginx 1.16.1)(MySQL 5.5.62) Performance Results Software Database Model Local QPS Cloud Server QPS Laravel 6.3.0 (with session) ORM 12.11 5.15 Laravel 6.3.0 (with session) PDO 13.85 5.31 Laravel 6.3.0 ORM 13.06 5.69 Laravel 6.3.0 PDO 13.98 5.89 Slim 4.3.0 PDO 41.04 43.65 PHP 7.1.9 Native PDO 52.85 51.81 Notes All tests performed using ApacheBench (ab) with command:</description></item></channel></rss>