<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Web Development on Infinite Script</title><link>https://www.infinitescript.com/categories/web-development/</link><description>Recent content in Web Development on Infinite Script</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sat, 24 Feb 2018 07:10:14 +0000</lastBuildDate><atom:link href="https://www.infinitescript.com/categories/web-development/index.xml" rel="self" type="application/rss+xml"/><item><title>Getting Started with JUnit 5: Test your Spring MVC Application with it</title><link>https://www.infinitescript.com/2018/02/getting-started-with-junit-5-test-your-spring-mvc-application-with-it/</link><pubDate>Sat, 24 Feb 2018 07:10:14 +0000</pubDate><guid>https://www.infinitescript.com/2018/02/getting-started-with-junit-5-test-your-spring-mvc-application-with-it/</guid><description>&lt;p&gt;In this post, we describe how to use JUnit 5 to test your Spring MVC application with Maven. Before diving into the &lt;code&gt;pom.xml&lt;/code&gt;, it helps to know that JUnit 5 is not a single library but three sub-projects: the &lt;strong&gt;Platform&lt;/strong&gt; (the foundation that discovers and launches tests), &lt;strong&gt;Jupiter&lt;/strong&gt; (the new programming and extension model you actually write tests against), and &lt;strong&gt;Vintage&lt;/strong&gt; (a backward-compatible engine that still runs your old JUnit 3/4 tests). This split is what makes the Maven coordinates below, and the &lt;code&gt;SpringExtension&lt;/code&gt; we plug in later, much less mysterious.&lt;/p&gt;</description></item><item><title>Making Requests Non-blocking in Tornado</title><link>https://www.infinitescript.com/2017/06/making-requests-non-blocking-in-tornado/</link><pubDate>Mon, 12 Jun 2017 11:58:46 +0000</pubDate><guid>https://www.infinitescript.com/2017/06/making-requests-non-blocking-in-tornado/</guid><description>&lt;p&gt;Tornado is one of the most popular web frameworks for Python, which is based on a single thread IO loop (aka event loop). You can handle high concurrency with optimal performance. However, Tornado is single-threaded (in its common usage, although it supports multiple threads in advanced configurations), therefore any &amp;ldquo;blocking&amp;rdquo; task will block the whole server. This means that a blocking task will not allow the framework to pick the next task waiting to be processed.&lt;/p&gt;</description></item><item><title>Single Sign-On with Apereo CAS</title><link>https://www.infinitescript.com/2017/02/configuring-apereo-cas/</link><pubDate>Tue, 14 Feb 2017 14:04:16 +0000</pubDate><guid>https://www.infinitescript.com/2017/02/configuring-apereo-cas/</guid><description>&lt;p&gt;This tutorial walks a newcomer through standing up an &lt;a href="https://www.apereo.org/projects/cas"&gt;Apereo CAS&lt;/a&gt; server for single sign-on and wiring a Java web application to it as a client. The complete CAS 7.1 server is available as a companion WAR overlay on &lt;a href="https://gitlab.com/hzxie/apereo-cas-webapp"&gt;GitLab&lt;/a&gt;.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This post has been rewritten for Apereo CAS 7.x. It was originally written for CAS 4.x, which you set up by copying the server source and hand-editing a pile of XML files (&lt;code&gt;deployerConfigContext.xml&lt;/code&gt;, &lt;code&gt;ticketGrantingTicketCookieGenerator.xml&lt;/code&gt;, …). CAS has changed completely since: the &lt;code&gt;org.jasig.cas&lt;/code&gt; packages became &lt;code&gt;org.apereo.cas&lt;/code&gt;, and the server is now built as a &lt;strong&gt;Spring Boot WAR overlay&lt;/strong&gt; configured through a single &lt;code&gt;cas.properties&lt;/code&gt; file.&lt;/p&gt;</description></item><item><title>Create a Desktop App with Angular 2 and Electron</title><link>https://www.infinitescript.com/2016/12/create-a-desktop-app-with-angular-2-and-electron/</link><pubDate>Mon, 12 Dec 2016 03:30:53 +0000</pubDate><guid>https://www.infinitescript.com/2016/12/create-a-desktop-app-with-angular-2-and-electron/</guid><description>&lt;p&gt;Last week, I took part in the Google Developer Day held in Beijing. The Angular team introduced their new Angular 2. Angular is a development platform for building mobile and desktop web applications.&lt;/p&gt;&#10;&lt;p&gt;&#10;&#10;&lt;a href="https://www.infinitescript.com/2016/12/Google-Developer-Day-2016-Beijing.webp" data-fancybox data-caption="Google-Developer-Day-2016-Beijing"&gt;&#10; &lt;img src="https://www.infinitescript.com/2016/12/Google-Developer-Day-2016-Beijing.webp" width="1024" height="768" alt="Google-Developer-Day-2016-Beijing" loading="lazy"&gt;&#10;&lt;/a&gt;&#10;&#10;&#10;&lt;/p&gt;&#10;&lt;p&gt;This tutorial shows how to configure and use Angular 2 web components with the Electron framework for creating native cross-platform applications with web technologies.&lt;/p&gt;&#10;&lt;p&gt;As recommended by the Angular team, TypeScript will be used throughout this tutorial. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. Any browser. Any host. Any OS. Open-source.&lt;/p&gt;</description></item><item><title>Use Server-Sent Events in Spring MVC</title><link>https://www.infinitescript.com/2015/06/use-server-sent-events-in-spring-mvc/</link><pubDate>Tue, 30 Jun 2015 02:55:32 +0000</pubDate><guid>https://www.infinitescript.com/2015/06/use-server-sent-events-in-spring-mvc/</guid><description>&lt;p&gt;Server-Sent Events (SSE) let a server push a continuous stream of updates to the browser over a single long-lived HTTP connection. Spring has supported them since version 4.2 through the &lt;code&gt;SseEmitter&lt;/code&gt; class, and the API has been stable ever since. This post is a practical how-to: we start with a bare &lt;code&gt;SseEmitter&lt;/code&gt;, then build the setup I actually use in production, streaming events from a message queue to the browser.&lt;/p&gt;</description></item><item><title>Use WebSockets with Spring, SockJS and Stomp</title><link>https://www.infinitescript.com/2015/05/use-websockets-with-spring-sockjs-and-stomp/</link><pubDate>Wed, 20 May 2015 14:42:45 +0000</pubDate><guid>https://www.infinitescript.com/2015/05/use-websockets-with-spring-sockjs-and-stomp/</guid><description>&lt;p&gt;This guide walks you through building a &amp;ldquo;hello world&amp;rdquo; application that sends messages back and forth between a browser and the server. WebSocket is a very thin, lightweight layer on top of TCP, which makes it a natural place to run a &lt;em&gt;subprotocol&lt;/em&gt; that gives the raw bytes some structure. Here we use &lt;a href="https://en.wikipedia.org/wiki/Streaming_Text_Oriented_Messaging_Protocol"&gt;STOMP&lt;/a&gt; messaging with Spring to create an interactive web application.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This post has been &lt;strong&gt;updated for Spring 6/7&lt;/strong&gt;. The WebSocket setup now uses &lt;code&gt;@EnableWebSocketMessageBroker&lt;/code&gt; Java configuration and the modern &lt;code&gt;@stomp/stompjs&lt;/code&gt; client. The original 2015 version targeted Spring 4.1 with XML &lt;code&gt;&amp;lt;websocket:message-broker&amp;gt;&lt;/code&gt; config and the legacy &lt;code&gt;Stomp.over()&lt;/code&gt; API; both are obsolete and have been replaced throughout.&lt;/p&gt;</description></item><item><title>Spring MVC MyBatis Integration Tutorial</title><link>https://www.infinitescript.com/2015/05/spring-mvc-mybatis-integration-tutorial/</link><pubDate>Sun, 03 May 2015 03:20:08 +0000</pubDate><guid>https://www.infinitescript.com/2015/05/spring-mvc-mybatis-integration-tutorial/</guid><description>&lt;p&gt;A while back I built a project on Spring MVC and Hibernate, then wanted to see how MyBatis compares. This article shows how to wire MyBatis into Spring MVC, and how to let Spring manage MyBatis transactions for you.&lt;/p&gt;&#10;&lt;p&gt;A database transaction is an all-or-nothing unit of work: either every statement in it takes effect, or none of them does. We lean on that property at the very end, where a single bad row makes an entire batch insert roll back.&lt;/p&gt;</description></item><item><title>Use CDN Service in Spring MVC</title><link>https://www.infinitescript.com/2015/04/use-cdn-service-in-spring-mvc/</link><pubDate>Thu, 02 Apr 2015 15:53:52 +0000</pubDate><guid>https://www.infinitescript.com/2015/04/use-cdn-service-in-spring-mvc/</guid><description>&lt;p&gt;When I deployed &lt;a href="https://www.infinitescript.com/project/testzilla/"&gt;TestZilla&lt;/a&gt; on &lt;a href="https://www.aliyun.com"&gt;Aliyun&lt;/a&gt; Elastic Compute Service, growing traffic made it worth offloading static files (images, CSS, and JavaScript) to a CDN. At the time there was little guidance on wiring a CDN into Spring MVC, so I &lt;a href="https://stackoverflow.com/questions/28734196/how-to-use-cdn-in-spring-mvc"&gt;asked on Stack Overflow&lt;/a&gt; and ended up with the setup below. The idea is simple: keep the CDN host in a single property and inject it wherever your JSP views reference static assets.&lt;/p&gt;</description></item><item><title>Create Unit Testing Cases in Zend Framework</title><link>https://www.infinitescript.com/2015/03/create-unit-testing-cases-in-zend-framework/</link><pubDate>Tue, 03 Mar 2015 02:30:45 +0000</pubDate><guid>https://www.infinitescript.com/2015/03/create-unit-testing-cases-in-zend-framework/</guid><description>&lt;p&gt;A solid unit test suite is essential for ongoing development in large projects, especially those with many people involved. Going back and manually testing every individual component of an application after every change is impractical. Your unit tests will help alleviate that by automatically testing your application’s components and alerting you when something is not working the same way it was when you wrote your tests.&lt;/p&gt;&#10;&lt;p&gt;The Zend Framework 2 API uses PHPUnit, and so does this tutorial application. A detailed explanation of unit testing is beyond the scope of this tutorial, so we will only provide sample tests for the components in the pages that follow. This tutorial assumes that you already have PHPUnit installed.&lt;/p&gt;</description></item><item><title>Create CDN View Helper in Zend Framework 2</title><link>https://www.infinitescript.com/2015/02/create-cdn-view-helper-in-zend-framework-2/</link><pubDate>Thu, 26 Feb 2015 11:26:08 +0000</pubDate><guid>https://www.infinitescript.com/2015/02/create-cdn-view-helper-in-zend-framework-2/</guid><description>&lt;p&gt;In this article, you will learn how to create a custom view helper in Zend Framework 2. A concrete example will be used; a helper which generates links for a subdomain, intended for storing static files. This is especially useful if you wish to use a Content Delivery Network (CDN). With very little modification, the helper can be made generic to support links to subdomains for all purposes.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Zend Framework 2 has reached end of life. In 2019 the project moved to the Linux Foundation and was renamed &lt;a href="https://getlaminas.org/"&gt;Laminas&lt;/a&gt;, so the &lt;code&gt;Zend\&lt;/code&gt; namespaces below are now &lt;code&gt;Laminas\&lt;/code&gt; (for example &lt;code&gt;Zend\View\Helper\AbstractHelper&lt;/code&gt; becomes &lt;code&gt;Laminas\View\Helper\AbstractHelper&lt;/code&gt;). The view-helper mechanics are otherwise unchanged, so this post is kept as a historical walkthrough. For a real project, run the namespaces through the &lt;a href="https://docs.laminas.dev/migration/"&gt;Laminas migration guide&lt;/a&gt; and follow the current &lt;a href="https://docs.laminas.dev/laminas-view/v3/helpers/advanced-usage/"&gt;custom view helper docs&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Sending Email with Spring MVC Using Template</title><link>https://www.infinitescript.com/2015/01/sending-email-with-spring-mvc/</link><pubDate>Sat, 10 Jan 2015 04:25:34 +0000</pubDate><guid>https://www.infinitescript.com/2015/01/sending-email-with-spring-mvc/</guid><description>&lt;p&gt;This tutorial walks through a small Spring MVC application that sends a templated e-mail, using Thymeleaf to render the message body and Jakarta Mail to deliver it.&lt;/p&gt;&#10;&lt;p&gt;It assumes you are comfortable with Java EE development and with building Spring MVC applications.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This post has been &lt;strong&gt;updated for Spring Framework 7 and Thymeleaf 3.1&lt;/strong&gt;. The original version rendered the message with Apache Velocity, but Spring deprecated its Velocity support in 4.3 and removed it entirely in 5.0; templating is now handled by Thymeleaf, and the mail dependency has moved from &lt;code&gt;javax.mail&lt;/code&gt; to Jakarta Mail (&lt;code&gt;jakarta.mail&lt;/code&gt;).&lt;/p&gt;</description></item><item><title>Spring AOP Example Using Annotation</title><link>https://www.infinitescript.com/2014/10/spring-aop-example-using-annotation/</link><pubDate>Fri, 24 Oct 2014 15:05:50 +0000</pubDate><guid>https://www.infinitescript.com/2014/10/spring-aop-example-using-annotation/</guid><description>&lt;p&gt;Spring Framework is developed on two core concepts – Dependency Injection and Aspect-Oriented Programming (AOP). Today we will look into the core concepts of Aspect-Oriented Programming and how we can implement it using Spring Framework.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This post has been &lt;strong&gt;updated for Spring Framework 7.0&lt;/strong&gt;. The original 2014 version targeted Spring 4.1 with AspectJ 1.8 and the &lt;code&gt;aspectjrt&lt;/code&gt; + &lt;code&gt;aspectjtools&lt;/code&gt; dependencies; it now uses &lt;code&gt;aspectjweaver&lt;/code&gt; 1.9.25 on the current Spring 7.0 GA line. Because Spring 7 builds on Jakarta EE, the servlet types in the examples now come from &lt;code&gt;jakarta.servlet.*&lt;/code&gt; rather than &lt;code&gt;javax.servlet.*&lt;/code&gt;. The AOP concepts and &lt;code&gt;@AspectJ&lt;/code&gt; annotations themselves are unchanged.&lt;/p&gt;</description></item><item><title>Sending Email with Zend Framework 2 Using Template</title><link>https://www.infinitescript.com/2014/10/zend-framework-2-send-html-mail-with-simple-template/</link><pubDate>Tue, 07 Oct 2014 08:12:31 +0000</pubDate><guid>https://www.infinitescript.com/2014/10/zend-framework-2-send-html-mail-with-simple-template/</guid><description>&lt;p&gt;Sending a templated HTML email is a one-liner in some frameworks, but Zend Framework 2 ships no such helper, so you have to wire up the view renderer, the MIME message, and the transport yourself. This post walks through that setup.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Zend Framework 2 has reached end of life. In 2019 the project moved to the Linux Foundation and was renamed &lt;a href="https://getlaminas.org/"&gt;Laminas&lt;/a&gt;; the &lt;code&gt;Zend\*&lt;/code&gt; classes shown below now live under &lt;code&gt;Laminas\*&lt;/code&gt; (e.g. &lt;code&gt;Laminas\Mail&lt;/code&gt;, &lt;code&gt;Laminas\View&lt;/code&gt;). The technique is unchanged, so this post still applies once you swap the namespaces.&lt;/p&gt;</description></item><item><title>WordPress $ is not defined</title><link>https://www.infinitescript.com/2014/08/wordpress-is-not-defined-even-if-jquery-is-loaded/</link><pubDate>Thu, 21 Aug 2014 04:29:54 +0000</pubDate><guid>https://www.infinitescript.com/2014/08/wordpress-is-not-defined-even-if-jquery-is-loaded/</guid><description>&lt;p&gt;If you copy a normal jQuery snippet into a WordPress theme or plugin, sooner or later you hit &lt;code&gt;Uncaught ReferenceError: $ is not defined&lt;/code&gt;. The confusing part is that jQuery itself &lt;em&gt;is&lt;/em&gt; loaded; your other jQuery code may even be working. So why does &lt;code&gt;$&lt;/code&gt; blow up?&lt;/p&gt;&#10;&lt;h2 id="why-it-happens"&gt;Why It Happens&lt;/h2&gt;&#10;&lt;p&gt;WordPress ships its own copy of jQuery and loads it in &lt;strong&gt;no-conflict mode&lt;/strong&gt;. On startup it effectively runs:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;jQuery&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;noConflict&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;noConflict()&lt;/code&gt; tells jQuery to give back control of the global &lt;code&gt;$&lt;/code&gt;. After it runs, &lt;code&gt;jQuery&lt;/code&gt; still points to the library, but &lt;code&gt;$&lt;/code&gt; no longer does; it is left free for some other library to claim.&lt;/p&gt;</description></item><item><title>Integrate Spring MVC with Log4j</title><link>https://www.infinitescript.com/2014/06/integrate-spring-mvc-with-log4j/</link><pubDate>Tue, 10 Jun 2014 04:46:09 +0000</pubDate><guid>https://www.infinitescript.com/2014/06/integrate-spring-mvc-with-log4j/</guid><description>&lt;p&gt;Integrating Log4j into a Spring MVC application is quite straightforward: include the Log4j library in your project dependencies, then create a &lt;code&gt;log4j.properties&lt;/code&gt; file to define Log4j&amp;rsquo;s appenders and put it on the project classpath. This tutorial walks through that with the Log4j 1.x logging framework.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This post targets &lt;strong&gt;Log4j 1.x&lt;/strong&gt;, which reached end of life in August 2015 and has known vulnerabilities (e.g. CVE-2019-17571, CVE-2021-4104). Treat it as a reference for maintaining legacy projects only. For anything new, prefer &lt;strong&gt;SLF4J + Logback&lt;/strong&gt; (the default in Spring Boot) or &lt;strong&gt;Log4j 2.x&lt;/strong&gt;. Their configuration and API differ entirely from what&amp;rsquo;s shown here, and the official link below now redirects to Log4j 2.&lt;/p&gt;</description></item><item><title>How does Ajax Work</title><link>https://www.infinitescript.com/2014/06/how-does-ajax-work/</link><pubDate>Thu, 05 Jun 2014 16:24:02 +0000</pubDate><guid>https://www.infinitescript.com/2014/06/how-does-ajax-work/</guid><description>&lt;p&gt;Ajax, a term coined by Jesse James Garrett that became popular after the publication of the article Ajax: &lt;a href="http://web.archive.org/web/20181231094556/https://www.adaptivepath.com/ideas/ajax-new-approach-web-applications/"&gt;A New Approach to Web Applications&lt;/a&gt; in February 2005, is short for Asynchronous JavaScript and XML.&lt;/p&gt;&#10;&lt;p&gt;The normal behavior of the Internet that involves sending pages to the browser is completely changed by the use of Ajax.&lt;/p&gt;&#10;&lt;p&gt;Ajax has become commonplace with its integration in HTML 5 and JavaScript frameworks, and in fact, the interest of developers has moved to HTML 5 for its new tags and APIs that accompany it. Among these, WebSocket appears as the successor to Ajax, because it is a superior means of communication between an application and the server or the backend.&lt;/p&gt;</description></item><item><title>Unit Testing for Spring MVC Controllers</title><link>https://www.infinitescript.com/2014/05/unit-testing-of-spring-mvc-controllers/</link><pubDate>Sat, 17 May 2014 02:09:38 +0000</pubDate><guid>https://www.infinitescript.com/2014/05/unit-testing-of-spring-mvc-controllers/</guid><description>&lt;p&gt;Once the services, DAO, and supporting classes are tested, it&amp;rsquo;s time for the controller. Controllers are often the hardest layer to test, so many developers (based on observation) reach for Selenium or, worse, test by hand. That works, but it makes exercising individual logic branches awkward and slow, and no one wants to wait for a browser to spin up before checking in code. The Spring MVC Test framework solves this by driving full controller logic through fast unit tests, and it has lived in Spring&amp;rsquo;s core ever since Spring 4.&lt;/p&gt;</description></item><item><title>Spring 4 MVC Hello World Tutorial Using Maven</title><link>https://www.infinitescript.com/2014/04/spring-4-mvc-hello-world-tutorial-using-maven/</link><pubDate>Sun, 20 Apr 2014 02:10:48 +0000</pubDate><guid>https://www.infinitescript.com/2014/04/spring-4-mvc-hello-world-tutorial-using-maven/</guid><description>&lt;p&gt;In this tutorial we build the smallest useful Spring MVC application: a controller that reads a request parameter and renders it in a JSP view. It is the classic &amp;ldquo;Hello World&amp;rdquo;, but the wiring it shows (a &lt;code&gt;DispatcherServlet&lt;/code&gt;, a bean configuration, and a view resolver) is the same wiring every larger Spring MVC application is built on.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This tutorial has been &lt;strong&gt;updated for Spring Framework 7&lt;/strong&gt;. It was originally written in 2014 for Spring 4 and the &lt;code&gt;javax.*&lt;/code&gt; servlet API; the configuration below now uses the &lt;code&gt;jakarta.*&lt;/code&gt; namespace, drops the Eclipse-specific setup for a plain Maven command, and runs on Jakarta EE 11 (Tomcat 11+). We keep XML configuration and &lt;code&gt;web.xml&lt;/code&gt; so every piece of the wiring stays visible. The same beans map one-to-one onto a &lt;code&gt;@Configuration&lt;/code&gt; class if you prefer Java config.&lt;/p&gt;</description></item><item><title>Zend Framework 2: Get Parameters</title><link>https://www.infinitescript.com/2014/02/zend-framework-2-get-parameters/</link><pubDate>Mon, 10 Feb 2014 03:49:35 +0000</pubDate><guid>https://www.infinitescript.com/2014/02/zend-framework-2-get-parameters/</guid><description>&lt;p&gt;The easiest way to read request parameters in a Zend Framework 2 controller is the &lt;a href="https://github.com/laminas/laminas-mvc/blob/master/src/Controller/Plugin/Params.php"&gt;Params plugin&lt;/a&gt;, introduced in beta5. It has utility methods to make it easy to access different types of parameters. As always, reading &lt;a href="https://github.com/laminas/laminas-mvc/blob/master/test/Controller/Plugin/ParamsTest.php"&gt;the tests&lt;/a&gt; can prove valuable to understand how something is supposed to be used.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Zend Framework 2 has been deprecated. The project moved to the Linux Foundation in 2019 and lives on as &lt;a href="https://getlaminas.org/"&gt;Laminas&lt;/a&gt;; the &lt;code&gt;Zend\&lt;/code&gt; namespace became &lt;code&gt;Laminas\&lt;/code&gt;, so the plugin shown here is now &lt;code&gt;Laminas\Mvc\Controller\Plugin\Params&lt;/code&gt; (in the &lt;code&gt;laminas/laminas-mvc&lt;/code&gt; package). The API is unchanged, so the examples below still apply after that rename.&lt;/p&gt;</description></item><item><title>Zend Framework 2: Redirect to 404 page in Controller</title><link>https://www.infinitescript.com/2014/02/zend-framework-2-redirect-to-404-page-in-controller/</link><pubDate>Fri, 07 Feb 2014 10:15:43 +0000</pubDate><guid>https://www.infinitescript.com/2014/02/zend-framework-2-redirect-to-404-page-in-controller/</guid><description>&lt;p&gt;I&amp;rsquo;ve been getting into trouble for several hours with redirecting to the 404 page in Zend Framework 2.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Zend Framework 2 has been deprecated. Zend Framework was migrated to the &lt;a href="https://getlaminas.org/"&gt;Laminas Project&lt;/a&gt; in 2020, where development continues today. The &lt;code&gt;notFoundAction()&lt;/code&gt; technique below still applies in laminas-mvc.&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;I asked about this on &lt;a href="https://stackoverflow.com/questions/21622849/use-the-same-error-handler-in-different-modules-in-zend-framework-2"&gt;Stack Overflow&lt;/a&gt;.&lt;/p&gt;&#10;&lt;h2 id="what-didnt-work"&gt;What Didn&amp;rsquo;t Work&lt;/h2&gt;&#10;&lt;p&gt;Before that, I was using the following code:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;getResponse&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;setStatusCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This sets the HTTP status code to 404, which looks fine at first. But it only changes the response header; it doesn&amp;rsquo;t dispatch the error controller, so once I built a custom 404 page I found that it never rendered.&lt;/p&gt;</description></item><item><title>Use CodeIgniter Resources within Library</title><link>https://www.infinitescript.com/2013/03/utilizing-codeigniter-resources-within-your-library/</link><pubDate>Sat, 02 Mar 2013 12:20:46 +0000</pubDate><guid>https://www.infinitescript.com/2013/03/utilizing-codeigniter-resources-within-your-library/</guid><description>&lt;p&gt;To access CodeIgniter&amp;rsquo;s native resources from inside your own library, use the &lt;code&gt;get_instance()&lt;/code&gt; function. It returns the CodeIgniter super object, the same one you reach through &lt;code&gt;$this&lt;/code&gt; inside a controller, so your library can load helpers, read config, or call any other class the framework has instantiated.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;code&gt;get_instance()&lt;/code&gt; is a CodeIgniter &lt;strong&gt;3.x&lt;/strong&gt; (and earlier) technique. CodeIgniter 4 dropped the global super object. There you reach framework features through &lt;a href="https://codeigniter.com/user_guide/concepts/services.html"&gt;Services&lt;/a&gt;, such as &lt;code&gt;service('session')&lt;/code&gt; or &lt;code&gt;\Config\Services::session()&lt;/code&gt;, or by injecting the dependencies your class needs through its constructor. Everything below applies to CodeIgniter 3.x.&lt;/p&gt;</description></item><item><title>Generate a Random File Name when Uploading Files in WordPress</title><link>https://www.infinitescript.com/2013/02/rename-files-during-upload-within-wordpress-backend/</link><pubDate>Mon, 18 Feb 2013 10:00:37 +0000</pubDate><guid>https://www.infinitescript.com/2013/02/rename-files-during-upload-within-wordpress-backend/</guid><description>&lt;p&gt;The passage is telling you how to rename the file name automatically by WordPress (without using any plugins).&lt;/p&gt;&#10;&lt;h2 id="a-word-of-warning"&gt;A Word of Warning&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt;: To apply this hack, you&amp;rsquo;ll have to edit one of WordPress&amp;rsquo;s core files. Keep in mind that it is never recommended. This hack should be redone if you upgrade WordPress.&lt;/p&gt;&#10;&lt;h2 id="editing-the-upload-handler"&gt;Editing the Upload Handler&lt;/h2&gt;&#10;&lt;p&gt;Open the wp-admin/includes/files.php file, and go to line 324 (approximately here). You&amp;rsquo;ll see the following:&lt;/p&gt;</description></item></channel></rss>