<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Middleware on Hari KT — Full Stack Developer</title>
    <link>https://harikt.com/tags/middleware/</link>
    <description>Recent content in Middleware on Hari KT — Full Stack Developer</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-GB</language>
    <copyright>© 2026 Hari KT</copyright>
    <lastBuildDate>Fri, 24 Mar 2017 00:00:00 +0000</lastBuildDate><atom:link href="https://harikt.com/tags/middleware/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>Building Modular Applications With PSR-7</title>
      <link>https://harikt.com/blog/2017/03/24/building-modular-applications-with-psr-7/</link>
      <pubDate>Fri, 24 Mar 2017 00:00:00 +0000</pubDate>
      
      <guid>https://harikt.com/blog/2017/03/24/building-modular-applications-with-psr-7/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://www.php-fig.org/psr/psr-7/&#34;  target=&#34;_blank&#34; rel=&#34;noreferrer&#34;&gt;PSR-7, the HTTP message interfaces&lt;/a&gt; opened&#xA;a new door of creating modular applications.&lt;/p&gt;&#xA;&lt;p&gt;Sadly many of the PSR-7 implementations added many helper methods.&lt;/p&gt;&#xA;&lt;p&gt;So if someone is creating a library that needs a PSR-7 implementations they tie&#xA;the particular library with the PSR-7 implementation and use these convinient helper methods.&lt;/p&gt;&#xA;&lt;p&gt;So was &lt;a href=&#34;https://github.com/http-interop/http-middleware&#34;  target=&#34;_blank&#34; rel=&#34;noreferrer&#34;&gt;PSR-15: interfaces for HTTP Middleware&lt;/a&gt;&#xA;and &lt;a href=&#34;https://github.com/http-interop/http-factory&#34;  target=&#34;_blank&#34; rel=&#34;noreferrer&#34;&gt;PSR-17: interfaces for HTTP Factories&lt;/a&gt;&#xA;was proposed.&lt;/p&gt;&#xA;&lt;p&gt;When creating a module one of the most challenging part is how to serve the&#xA;javascript, css and images. We are going to use&#xA;&lt;a href=&#34;github.com/harikt/psr7-asset&#34; &gt;hkt/psr7-asset&lt;/a&gt; which is a fork of&#xA;&lt;a href=&#34;https://github.com/friendsofaura/Aura.Asset_Bundle/&#34;  target=&#34;_blank&#34; rel=&#34;noreferrer&#34;&gt;Aura.Asset_Bundle&lt;/a&gt; .&#xA;What you want to do is only map the path to the assets folder.&lt;/p&gt;</description>
      
    </item>
    
    <item>
      <title>Eloquent and Pagination Inside Zend Expressive</title>
      <link>https://harikt.com/blog/2015/11/13/eloquent-and-pagination-inside-zend-expressive/</link>
      <pubDate>Fri, 13 Nov 2015 00:00:00 +0000</pubDate>
      
      <guid>https://harikt.com/blog/2015/11/13/eloquent-and-pagination-inside-zend-expressive/</guid>
      <description>&lt;p&gt;Recently working with eloquent (Laravel&amp;rsquo;s orm), zend expressive and zend view,&#xA;I wanted to integrate pagination.&lt;/p&gt;&#xA;&lt;p&gt;It was simple as registering a &lt;code&gt;Paginator&lt;/code&gt; middleware.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight-wrapper&#34;&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;&#xA;&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td class=&#34;lntd&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;?&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;php&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;use&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Illuminate\Pagination\Paginator&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;use&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Psr\Http\Message\ResponseInterface&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;use&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Psr\Http\Message\ServerRequestInterface&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;IlluminatePaginator&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;currentPageResolver&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;function&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$pageName&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;use&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$request&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nv&#34;&gt;$params&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;$request&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;getQueryParams&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;empty&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$params&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$pageName&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;])&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;?&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;$params&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$pageName&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;];&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;});&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;IlluminatePaginator&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;currentPathResolver&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;function&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;use&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$request&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;$request&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;getUri&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;getPath&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;and you can call paginate on the &lt;code&gt;Model&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Eg : Consider you have a &lt;code&gt;Post&lt;/code&gt; model.&lt;/p&gt;</description>
      
    </item>
    
    <item>
      <title>Conduit: Middleware for PHP</title>
      <link>https://harikt.com/blog/2015/01/21/conduit-middleware-for-php/</link>
      <pubDate>Wed, 21 Jan 2015 00:00:00 +0000</pubDate>
      
      <guid>https://harikt.com/blog/2015/01/21/conduit-middleware-for-php/</guid>
      <description>&lt;p&gt;Long back, I happened to talk with &lt;a href=&#34;https://beau.io/&#34;  target=&#34;_blank&#34; rel=&#34;noreferrer&#34;&gt;Beau Simensen&lt;/a&gt; about &lt;a href=&#34;http://stackphp.com/&#34;  target=&#34;_blank&#34; rel=&#34;noreferrer&#34;&gt;stackphp&lt;/a&gt; on #auraphp channel. It was hard for me to digest when I noticed it need &lt;code&gt;symfony/http-kernel&lt;/code&gt; and its dependencies.&lt;/p&gt;&#xA;&lt;p&gt;After a few months, I started to like the middleware approach of slim framework and wanted to push it to aura. But nothing happened  there.&lt;/p&gt;&#xA;&#xA;&lt;h2 class=&#34;relative group&#34;&gt;Conduit to rescue&#xA;    &lt;div id=&#34;conduit-to-rescue&#34; class=&#34;anchor&#34;&gt;&lt;/div&gt;&#xA;    &#xA;    &lt;span&#xA;        class=&#34;absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none&#34;&gt;&#xA;        &lt;a class=&#34;text-primary-300 dark:text-neutral-700 !no-underline&#34; href=&#34;#conduit-to-rescue&#34; aria-label=&#34;Anchor&#34;&gt;#&lt;/a&gt;&#xA;    &lt;/span&gt;&#xA;    &#xA;&lt;/h2&gt;&#xA;&lt;p&gt;Conduit is a Middleware for PHP built by &lt;a href=&#34;http://mwop.net/&#34;  target=&#34;_blank&#34; rel=&#34;noreferrer&#34;&gt;Matthew Weier O&amp;rsquo;Phinney&lt;/a&gt; lead of Zend framework. Conduit supports the current &lt;a href=&#34;https://github.com/php-fig/fig-standards/blob/master/proposed/http-message.md&#34;  target=&#34;_blank&#34; rel=&#34;noreferrer&#34;&gt;PSR-7 proposal&lt;/a&gt;. I believe like the many PSR&amp;rsquo;s, PSR-7 will be a revolution in the PHP world. Conduit is really a micro framework and can grow with your project.&lt;/p&gt;</description>
      
    </item>
    
  </channel>
</rss>
