What is Laminas Project?

And why use it

@juliansomesan

WEUC 2024

Julian Somesan

  • Coding since 1995
  • PHP since 2001
  • CTO at Apidemia (Laminas Commercial Vendor)
  • Technical consultant
  • Laminas Technical Steering Committee member

Long-term vs hit & run

Milk the cow vs eat the cow right now

Laminas Project

  • Formerly Zend Framework
  • Community-supported, open source project
  • Enterprise-ready PHP components
  • Mezzio middleware

The olden days

Historical PHP major vulnerabilities

  • SQL injections -> PDO, zend_db
  • sending emails -> zend_mail

Lack of standardization

  • Vendor lock-in
    • Good for developer (more or less)
    • Bad for client
  • Chaotic architecture
    • Bad for everybody

Zend framework 1

Built as a collection of libraries, not a monolith framework

Standardization

The modern world is built on standards

  • Deutsches Institut für Normung

Standards for products and services ensure

  • Safety
  • Quality
  • Reliability

PHP Standard Recommendation (PSR)

PSRs are published by the PHP Framework Interoperability Group (PHP-FIG)

In code, PSRs are interfaces that must be implemented

Laminas Project, its components and its Mezzio microframework follow as many PSRs as is possible and feasible

The goal is to implement all PSRs (eventually)

PSR in Mezzio microframework

  • PSR-7: HTTP Message Interface
  • PSR-15: HTTP Handlers
  • PSR-17: HTTP Factories

General PSR: 0, 1, 2, 3, 4 etc.

Laminas components updates

  • Evolution of PHP
    • Generates backward incompatibilities
  • Evolution of PHP
    • Generates backward incompatibilities
  • Evolution of PSRs
    • Changes for system architecture
    • Updates for interface implementation
PSR-2
PSR-12

PSR methodology

  • RFC documents contain technical specifications and organizational notes for the Internet and are the core output of the IETF
  • RFC documents contain technical specifications and organizational notes for the Internet and are the core output of the IETF
  • PSR contains the theoretical definition of the RFC
  • RFC documents contain technical specifications and organizational notes for the Internet and are the core output of the IETF
  • PSR contains the theoretical definition of the RFC
  • Coding the interface
  • RFC documents contain technical specifications and organizational notes for the Internet and are the core output of the IETF
  • PSR contains the theoretical definition of the RFC
  • Coding the interface
  • Implementing the interface
RFC
PSR-11
psr/container interface
interface implementation

PSR methodology examples

PSR-3 Logger

Repo: https://github.com/php-fig/log

Namespace: Psr\Log

  • php-fig - GitHub org name
  • log - standard name

PSR-11 Container interface (servicemanager)

Namespace: Psr\Container

  • v1 - laminas/laminas-servicemanager 3
  • v2 - laminas/laminas-servicemanager 4
    • created from PSR-11 errata
    • psr/container breaks backward compatibility

PSR-3 Logger Interface

Standards are evolving along with the PHP version

  • php-fig/log version 1
    • implements PSR-3 Logger, requires PHP >=5.3.0

PSR-3 Logger Interface

Standards are evolving along with the PHP version

  • php-fig/log version 1
    • implements PSR-3 Logger, requires PHP >=5.3.0
  • php-fig/log version 2
    • breaks BC by using PHP 8.0

PSR-3 Logger Interface

Standards are evolving along with the PHP version

  • php-fig/log version 1
    • implements PSR-3 Logger, requires PHP >=5.3.0
  • php-fig/log version 2
    • breaks BC by using PHP 8.0
  • php-fig/log version 3
    • breaks BC by adding return type

Standards are evolving

  • PSR-2: Coding Style Guide
    • Replaced by PSR-12 and PER
  • PSR-3: Logger Interface v1, v2, v3
  • PSR-11: Container Interface v1, v2

Long-term vs hit & run

Milk the cow vs eat the cow right now

Using Laminas-Mezzio

Laminas enterprise-ready PHP components

  • dependency injection
  • event dispatchers
  • input validation and filtering
  • pagination
  • navigation
  • feed generation
  • parsing
  • much, much more

Mezzio PHP middleware application

  • PSR-7 (HTTP Messages)
    • Request -> Middleware -> Response
  • PSR-15 (HTTP Request Handlers)
  • Routing
  • Templating
  • Dependency injection container

Laminas-Mezzio guarantee

  • Regular updates
  • High competency
  • Use of standards (PSR)
  • Unopinionated

Laminas Ecosystem in Dotkernel

  • 40+ package wrappers
    • Support for most recent versions
  • Projects
    • Frontend
    • API
    • Admin
  • All open source

Ending notes

  • Laminas Project is not a framework
    • Frameworks can be built in minutes
    • Promotes code decoupling
  • Laminas-Mezzio implements PSR
    • Future-proof stability
    • Does not reinvent the wheel
  • The true goal of frameworks
    • Default functionalities at high level
  • Frameworkitis
    • Tries to do too much
    • Doesn't allow changes

Questions?