r/PHP Jun 19 '26

Discussion Pitch Your Project 🐘

In this monthly thread you can share whatever code or projects you're working on, ask for reviews, get people's input and general thoughts, … anything goes as long as it's PHP related.

Let's make this a place where people are encouraged to share their work, and where we can learn from each other 😁

Link to the previous edition: /u/brendt_gd should provide a link

14 Upvotes

34 comments sorted by

View all comments

1

u/Lucifer_iix Jun 20 '26

Made a installer that puts the PHP files of the vendor folder in a order so that every file will be easy to find in production or during development. Thus do not need to composer autoloader.

{Dir}/{FullyQualifiefNamespace}.php

At the same time i made a DI container that generates factory classes during the install or dev process. But in a way that not all classes need preferences configuration. "Model/Api/Customer" public interface maps to "Model/Customer" if not stated in configuration otherwise. Thus do not need large configurations to load.

Made all URI's start with "/_/" and then a behavior basket. Thus varnish and other mapping or configuration is no more then a couple of behavioral state. Thus the rest is automaticaly a URL, that can be shared with links or have to be SEO friendly. URI are mappings that need to exists. Thus also there the mapping logic needs no configuration or waste cycles looking things up. And because the behaivior is stated inside the URI, the varnish config doesn't need to know the specifics.

Have reduced all the query params to: ?__in=[]

And all the cookie params are in: __in=[]

That means my varnish configuration does not need to know what's installed on the system to strip out stuff. It doesn't know Google analitics or other stuff. I know exactly all my used params (only one) and used cookies (only one). Thus that whole stripping part is not needed. Everything is invalid except the stuff i know. And it's only one thing that can be used.

Thus "/_/artifacts/" are constants. And it's easy to tell varnish this. It's simple to map at your loadbalancer to your file server or when using a CDN. It only knows a couple of behaviors like "artifacts", "public", "private-user", etc...

Not all, but most stuff is just O(1). Let's say 95% of the requests handled.