What is Laminas Project?

And why use it

Historical PHP major vulnerabilities

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

Zend framework 1

Built as a collection of libraries, not a monolith framework

Standardization

Lack of standardization

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

The modern world is built on standards

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 V1
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

psr/container -> V1 service manager 3

PSR-11

  • v1 - service manager 3
  • v2 - service manager 4

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
  • Laminas-servicemanager v4

Long-term vs hit & run

Milk the cow vs eat the cow right now

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