Dotkernel Light is a PSR-15 compliant application that uses the Mezzio microframework and Laminas components. It’s aimed at creating a simple website, like a presentation site, but can be expanded as needed.

Dotkernel Light has come a long way since our last update. It’s just as useful for a presentation site, but our perfectionist devs thought we could do better. Let’s see what we have improved to make your use of Light that much more convenient.

Migrating from controllers to handlers

dotkernel/dot-controller isn’t going away, but we have switched to PSR-15 handlers instead. PSR-7 HTTP message interfaces defines the request handler as an individual component that processes a request and produces a response. Given that it’s used in a middleware architecture, the request can be wildly different (e.g. filtered, augmented) by the time it reaches your custom code. Handlers split the code into more manageable chunks and cleaner file structure. An added benefit is it allows us to figure out an application’s functionality easier. We will expand on this aspect further down in the article, in the ‘Naming pattern’ chapter.

Implementing PSR-15 compatible handlers

We are striving to implement every feature with the most modern standards and design patterns in mind. The PHP Framework Interop Group defines PSR-15 as common interfaces for HTTP server request handlers and HTTP middleware that use HTTP messages as described by PSR-7. The MVC design pattern is considered obsolete by respected members of the PHP community, so we are replacing it with Middleware and HTTP message desing pattern.

Adopting a naming pattern for PSR-15 handlers

Now the file names reflect the functionality at a glance. We devised a naming pattern for our PSR-15 handlers that highlights the method, resouce and action for each file to make navigation and onboarding that much easier. We like to keep things tidy, as well as informative.

Implementing Vite

Vite replaces webpack as our static modules bundler. It concatenates and compresses .css and .js files to enable faster downloads. It also preprocesses .scss files into .css. As far as devs using Light are concerned, Vite was configured to work similarly to webpack. We decided the technical advantages like easier dependency management and execution speed justified the migration to Vite. It’s also highly recommended by the PHP community.

Replacing Psalm with PHPStan

Both Psalm and PHPStan are respected and widely-used static analysis tools. Some of the big names in the PHP ecosystem have opted for the same switch, so we decided to follow suit. Ultimately, the functionality is similar to our previous tool, but the growing interest and improved detection quality make PHPStan a great choice for our applications. PHPStan is configured to run at rule level 8 to help prevent bugs and write better code.

Other updates

Some of the smaller updates involve:

  • Adding support for PHP 8.4.
  • Enabling PHPStan and Qodana to run for PHP 8.4 as well.
  • Cleaning up and adapting the error configuration file to make use of the latest features.
  • Updating laminas/laminas-coding-standard to the latest major version.
  • Updating composer.json to make sure it’s up-to-date with the latest releases for each dependency, as well as to remove any now-obsolete items.
  • Implementing a more reliable and efficient post install script to help get you up and running that much faster.
  • Removing dotkernel/dot-twigrenderer in favor of a direct implementation of mezzio/mezzio-twigrenderer.

Additional resources

Dotkernel Light Git

Dotkernel Light demo

Dotkernel Light documentation

PHP Framework Interop Group

PSR-15: HTTP Server Request Handlers

Static Analysis – Replacing Psalm with PHPStan


Looking for PHP, Laminas or Mezzio Support?

As part of the Laminas Commercial Vendor Program, Apidemia offers expert technical support and services for:

  • Modernising Legacy Applications
  • Migration from any version of Zend Framework to Laminas
  • Migration from legacy Laminas API Tools (formerly Apigility) to Dotkernel API
  • Mezzio and Laminas Consulting and Technical Audit
  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>