I'm Building My Own PHP Platform, and I've Been Learning a Lot Along the Way
I'm a self-taught developer, and for some time now, I've been working on a project called Domain System.
It started with an idea: what if I could build my own PHP platform, where the main system and its plugins had their own responsibilities and didn't depend too much on each other?
As I kept working on it, the project grew. I had to think about how to organize the code, how plugins should communicate with the core, how to handle errors, and how to avoid breaking something that was already working.
I won't pretend I have all the answers. I'm still learning, making mistakes, and going back to improve things. But that's part of what makes this project interesting to me.
You can find it on GitHub here:
https://github.com/hadelrachid/domain-system
Why I started thinking differently about PHP
When I started thinking about how to organize the project, I became interested in how operating systems separate their essential parts from the applications that run on top of them.
I wondered if I could borrow a little of that idea for a PHP platform.
In Domain System, I try to keep two things separate:
- The core: The part responsible for things the system needs to work, such as routing, storage, and other shared services.
- The plugins: The parts that add features to the platform.
The idea is simple: I don't want the core to know all the details of every plugin. I'd rather have them communicate through interfaces, so I can change one part without having to change everything else.
In practice, getting this right is harder than it sounds. You can create interfaces and still end up with code that's too dependent on other classes. That's something I've been learning to pay more attention to as the project develops.
Some things I've been working on
Installing plugins more safely
One thing that made me think carefully was plugin installation.
When you upload a ZIP file, you can't simply assume that every file inside it is safe to extract wherever you want.
So I added a step where uploaded files are checked before they're moved into place. The process includes checks for problems such as path traversal and ZIP Slip.
It's not something I'd describe as a guarantee that every possible attack is prevented. Security takes more than a few checks, and I know this is an area that deserves ongoing attention.
Trying to make problems easier to recover from
Another challenge is dealing with errors without leaving the system in a bad state.
Domain System includes JSON storage, file-locking and atomic-write techniques, diagnostic tools, and a snapshot and rollback feature.
These are attempts to make problems easier to identify and recover from. I know things can still go wrong, but I'd rather build ways to deal with failures than assume they won't happen.
Building my own visual page editor
I've also been working on Flex Builder, a visual editor for creating page layouts and theme components.
One thing I wanted was for the editor preview to behave as closely as possible to the actual website. To help with that, both use the same compilation process.
I've also been working on responsive layouts, so that hiding an element on a smaller screen doesn't leave awkward empty spaces behind.
There are plenty of details to work through in an editor like this, and it's been a good learning experience.
Using AI without losing control of my code
I also use AI coding tools to help me develop the project.
They can be very useful, especially when you're working on a large codebase. But I've learned that getting code that works in isolation isn't the same as getting code that fits the rest of the project.
Sometimes a change can solve one problem while creating another. A new class might work, for example, but introduce dependencies that make future changes harder.
To help avoid this, I've been creating documentation and rules that explain how the project is organized and how new plugins should be built. There's also a command-line tool to generate a basic plugin structure.
I'm still figuring out the best way to use AI without letting the code become difficult to maintain. Documentation helps, but I still need to review the changes and understand what they're doing.
A little about the technology
Domain System is built with PHP 8.2+. It supports MySQL/MariaDB and SQLite through PDO, as well as its own JSON storage option.
I use PHPUnit for automated tests. At the time of writing, the project has 433 tests and more than 2,340 assertions.
Those numbers are useful, but I don't think they tell the whole story. Passing tests are important, and so is checking whether the code is organized in a way that makes sense and can be maintained over time.
I'm sharing it because I'd like to learn from others
This project has taught me that building something is one challenge; keeping it understandable as it grows is another.
I'm not presenting Domain System as a finished solution or claiming that I've found the best way to build a PHP platform. It's a project I'm developing, learning from, and trying to improve.
If you have a moment to look at the code, I'd really appreciate your thoughts.
For example:
- Does separating the core from the plugins this way make sense to you?
- How do you keep a PHP project organized as it grows?
- If you use AI to help write code, how do you make sure the changes still fit your project's design?
I'd be happy to hear suggestions, questions, or even criticism. I'm sharing the project partly because I know other developers may notice things that I haven't.
Here's the repository:
https://github.com/hadelrachid/domain-system
Thanks for taking the time to read this!

Top comments (0)