Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Roll your own micro framework

Niklas Modess
September 07, 2015

Roll your own micro framework

Are micro frameworks the future? When you choose a framework your often have to make compromises and you couple your code to the framework itself. Let’s explore how we can create our own micro framework we can tailor for our application’s needs and how it fits well in a service oriented architecture.

Niklas Modess

September 07, 2015
Tweet

Other Decks in Programming

Transcript

  1. Roll your own
    micro framework

    View full-size slide

  2. Me, myself & I
    Niklas Modess
    Remote freelancer / consultant
    Organizer of Laravel Stockholm meetup group
    Author of Deploying PHP Appplications
    Blogger at http://modess.io
    @niklasmodess

    View full-size slide

  3. Framework (de)coupling

    View full-size slide

  4. SHOTS FIRED, COMMENCE FLAME
    WARS!

    View full-size slide

  5. Service oriented
    architecture
    (Micro Services)

    View full-size slide

  6. Simple RESTful API with Laravel?
    4 classpreloader/classpreloader
    4 danielstjules/stringy
    4 doctrine/inflector
    4 jeremeamia/superclosure
    4 league/flysystem
    4 monolog/monolog
    4 mtdowling/cron-expression

    View full-size slide

  7. 4 nesbot/carbon
    4 psy/psysh
    4 swiftmailer/swiftmailer
    4 symfony/console
    4 symfony/css-selector
    4 symfony/debug
    4 symfony/dom-crawler
    4 symfony/finder

    View full-size slide

  8. 4 symfony/http-foundation
    4 symfony/http-kernel
    4 symfony/process
    4 symfony/routing
    4 symfony/translation
    4 symfony/var-dumper
    4 vlucas/phpdotenv

    View full-size slide

  9. S.O.L.I.D
    4 Single responsibility principle
    4 Open/closed principle
    4 Liskov substitution principle
    4 Interface segregation principle
    4 Dependency inversion principle

    View full-size slide

  10. Inversion of Control
    IoC

    View full-size slide

  11. instead of this...
    use MicroFramework\Router;
    $router = new Router;
    // some code..
    $router->dispatch();

    View full-size slide

  12. we do this...
    $container = require __DIR__ . '/bootstrap.php';
    $router = $container->get('Router');
    // some code..
    $router->dispatch();

    View full-size slide

  13. Let's build stuff
    4 Application container (DI/IoC)
    4 Router interface
    4 Router implementations
    4 Hot-swapping router implementations

    View full-size slide