Going framework-agnostic with BDD

Introduction to BDD and hexagonal architecture in PHP

Target audience:

Software Developers & Architects familiar with PHP development, but not familiar with BDD methodology and designing domain focused applications independent from infrastructure elements and tools.


20% lecture and 80% hands-on coding


1 day


Having code that is not coupled with any framework has a lot of profits. There is a small probability that you will change a framework during the lifecycle of the project. But,  that kind of approach gives you an easy way to reuse some of the functionalities across different styles of user interaction. GUI? API? Console command? Easy peasy with small effort. Also, it helps with testability and evolution of the codebase. Everything with a high understanding of the domain you are working for.

During this workshop, you will learn how working closely with business on defining their needs. That can help you create clean code that you will love to work in long term projects. You will learn how to write user stories and scenarios of use cases using Gherkin language. We will focus on how to write scenarios that will encourage domain experts to work together with you on designing the system. It will also keep them engaged for the whole lifecycle of the product. You will see how to use Behat to design how your system will communicate with the outside world. Using  PHPSpec you will work on internal communication between the building blocks of code.

In the end, you will learn how to integrate that kind of system with the framework and infrastructure of choice. We will do it in the way, where those tools will not gain control over the way you are developing your project.

Learning outcomes:

  • Write BDD scenarios with language common with business.
  • Design high-level code behaviour with story BDD techniques and low-level code behaviour with spec BDD techniques.
  • Automate BDD scenarios to become acceptance functional tests.
  • Isolate domain application logic from infrastructure and UI related code.
  • Integrate framework agnostic application with framework and infrastructure tools of choice.
  • Implement commands and handlers as the abstraction of user intention in the system


  • Introduction
    • what is BDD
    • levels od BDD
    • tools in the PHP ecosystem
  • Writing scenarios
    • scenarios sources
    • focus on the business domain
    • type of scenarios
    • specification by example
  • Scenarios automation
    • different ways of automation
    • usage of automation to design code
  • Spec BDD
    • ways of design code on the unit level
    • unit isolation and mocks 
  • Hexagonal architecture
    • layers of system
    • isolation from  tools and infrastructure
  • Integration with infrastructure
    • integration with framework (Symfony example)
    • integration with storage (DB example)


  • Proficiency in programming in PHP language
  • Laptop/notebook with a working development environment:
    • newest PHP version
    • composer
    • relational database with the ability to connect to
  • Ability to connect  to the Internet

Room setup:

  • Cabaret or boardroom style setup
  • Projector/screen
  • Whiteboard/flipchart
Going framework-agnostic with BDD
Scroll to top