DPC2019: Crazy Fun Experiments with PHP (Not for Production) - Zan Baldwin

Php

Explore the unconventional and creative ways to extend PHP's capabilities with innovative experiments in PHP streams, stream filters, Aspect-Oriented Programming, and metaprogramming.

Key takeaways

PHP streams and stream wrappers

  • Streams are a fundamental aspect of PHP development, enabling input/output operations
  • PHP cores supports several protocols: file, https, ftp, ssh, etc.

Aspect-Oriented Programming (AOP)

  • AOP is a framework for developing PHP applications using metaprogramming
  • It allows modifying the behavior of classes and methods at runtime

Generating code on the fly

  • Use a code template to generate valid PHP code
  • Demonstrate how to use a stream filter to modify the code before execution

Auto-loader overloading

  • Discuss the auto-loader overloader, which hijacks the normal composer logic
  • Use it to generate code on the fly and register it with PHP

Encrypted source code

  • Discuss the example of encrypted source code and how it can be decrypted
  • Use a simple encryption method to demonstrate the process

Streams and Stream Filters

  • Explain how streams can be used to manipulate data as it passes through
  • Discuss the use of stream filters to modify the stream data

Aspect-Oriented Programming (AOP) Techniques

  • Discuss the use of AOP to interrupt the execution flow of code
  • Explain how AOP can be used to add logic at specific points in the code

Error Handling

  • Discuss how error handling can be achieved in AOP
  • Explain how exceptions can be handled and caught using AOP

Metaprogramming

  • Discuss the concept of metaprogramming and its relevance to AOP
  • Explain how AOP enables metaprogramming in PHP