Skip to main content

One post tagged with "architecture"

View All Tags

The Challenges of Building a Single-File PHP Framework

· 4 min read
Noor Team
Framework Maintainer

Building a framework in a single file sounds like a constraint you'd impose for fun. And it was fun. But it also forced some interesting trade-offs that are worth documenting.

1. Namespace Management in a Flat File

Without Composer's PSR-4 autoloader, every class lives in the global namespace. That means class name collisions are a real possibility if the user brings in external libraries or defines their own classes.

The solution was a simple spl_autoload_register at the bottom of noor.php that checks the project root, controllers/, and models/ directories. User classes take priority over framework internals. This buys reasonable interoperability without compromising the single-file constraint.