Hi!

I'm Marco!

Ocramius

Building a micro-framework with ZendFramework

Why ZendFramework
and not
ZendFramework 3?

ZF3 is not yet complete

ZF3 is also not a complete revolution

Fear not

...for the path is clear!

Tiny steps, big evolution

The framework ecosystem changed

More people like "no-framework" approaches

More granular components and libraries

Less tolerance towards framework coupling

Diverging Practices

Static site generators

More focus on Domain Logic in complex Domains

These are GOOD improvements!

We will also start from scratch

No framework

Domain first

Exploring advantages and limitations

Our example: Poker

Very specific Domain Language

Very specific Domain Rules

Not too complex

Plus we're in Vegas!

Poker phases

  1. Small blind
  2. Big blind
  3. Fold
  4. Call (under the gun)
  5. flop
  6. turn
  7. river
  8. showdown

Poker actions

  • Join a game
  • Post a blind
  • See own cards
  • See community cards
  • Fold
  • Call
  • Bet
  • Check
  • Tap (same as Check)

Let's see the Code!

Our first Poker app

No frameworks

Minimal

Straight to the point

Nothing else but domain endpoints

MOAR Code!

Some Advantages:

Easy to understand

Minimal

Some Disadvantages:

One missed break; and BOOM!

What if we want to add security?

What if we want to add CORS?

What if we want to have templating?

What if we want to add logging?

There is a constant NEED for Flexibility

We may hope for a stable specification

We know we won't get it

(for me) flexibility = refactoring quickly

We need to partition our code

We need to add some kind of "pluggable functionality"

We still want to keep it Micro

Our app is small

We want to keep it small

We want to stay fast in changing!

Pick a Micro-Framework?

Introducing ZF2 usage

That's just my personal choice

Other frameworks are also OK

We use ZeffMu to make it micro

Let's see the Code!

Advantages:

Easy to understand

Minimal

Plugin system (Modules)

Event system (EventManager)

Dependency Injection (ServiceManager)

Disadvantages:

Kind-of bloated file (may need to split)

The controller helpers are too magic?

Some framework coupling

A zend-expressive example

It is not about ZendFramework anymore

What new things can we do?

Integration with other Frameworks

We can talk to Slim 3

We can talk to Symfony 3

We can talk to Drupal 8

We can build our own web server (or use a PSR-7 compliant one)

Use other PSR-7 Middlewares

Remember StackPHP?

We can modify request/response as we wish

Replace the session system? (Ocramius/StorageLessSession)

There is some ZF3 already in it

You just didn't notice it

That also is a good thing!

Unnoticeable upgrades, big low-level impact

Thanks!