Modern Open Source PHP, OOP, PSR and the race to the bottom (programming)
Page is part of Articles in which you can submit an article
written by owen on 2023-Jan-08.
Reddit/PHP is a unique echochamber which exhibits certain traits and patterns. This is a software development rant. I evaluate software everyday to determine how useful it is to me and to others. Software is being created all the time around the world, some of this software is doomed from the start. Others are posted on reddit/PHP in order to generate attention, approval or commentary - I am not sure why exactly because reddit is a cold place. But we are going to look at what seems to be the typical way it goes down - at least on reddit. I am going to do a deep dive on this reddit thread.
This is common in basically every posted project. There is a misconception that software being "open source" is an advantage and alot of emphasis is placed on the "open sourceness" even though it does not matter, no one cares. Modern PHP code is so generic and it might as well be generated by A.I. - there is no point in reading it or open sourcing it. If it's OOP you know it's going to be eating its own dog food like every other PHP PSR OOP project.
Designed to Make things Easy
There are many projects that claim to solve a problem by making it easy. Easy is a fool's errand. It is fine to spend a year coding something that is "easy to use" but has hidden headaches in a rat's nest of API calls. What is this "easy" that marketing people talk about? Who is it directed towards? admins? end users? small business? reddit users? programmers? Certainly can't be everyone. No one knows, it's nebulous. It can be easy but most likely not in the way that you think.
On top of Modern Stack
This "modern stack" meme also comes with a whole lot of baggage because it is a moving target. No one determines what is modern or legacy. Pundits throw the term around to promote the fancy new cluster-fk of tools that someone has thrown together and convinced others to use. What was modern yesterday is legacy tomorrow. It all depends on who you are talking to and what middleman role they are shilling. Anything can be modern and there is no upper limit.
Working on this PHP project for a while
I can only imagine that devs in the PHP Standard Recommendation (PSR) Workflow ecosystem live a lonely life. If they post their work that they spent 3 years constructing to be PSR compliant, the first comment will be "but X does this already!" or "framework Y does it more efficiently". IT does not matter how good it is or how close they follow the spec. They have already lost because they are given a wheel in which to re-invent which is enormous and ever growing. You can show your wheel until it meets a baseline of 10k lines of boilerplate code. Hello world? gtfo!
There are tons of plugins out there that hope to one day get enough stars to be relevant. Because of the nature of OOP+PSR you could spend many years programming and still come out with a boring text file of class definitions that no one even looks at because they know what's there and they also know it's a dead end. So much time is wasted by new programmers just trying to meet these recommendations. It is large scale cargo cult programming designed to sterilize new innovations by standardizing how people think about solutions to problems. Part of it is to keep the giant PHP framework projects relevant and chugging along getting bigger and bigger. There are always easier ways to do things.
If you would like to contribute, fork my repository
Alot of those projects hope to attract contributors but the way I see it; if you have the skills to contribute to such a new project then you most likely have the skills to create the whole thing yourself. This is another itch that I have with OOP projects; no matter how well you string your object/classes together it's never perfect or universal. I have told the story of a OOP programmer who would redesign his object structure every 6 months with the goal of making the perfect structure - it's a kind of paranoid schizophrenia.
It is even worse if you want someone else with the same disease to fork code that you spent X years gluing together. If they change the structure there is no way you are going to accept the pull request that messes with your almost perfect mental model. Bigger projects get around this by just being huge and directed by one person or a team. So contributors are left with minor busy work tasks or expanding in allowed areas. The hand that rules the project rules the world.
First Comment: No Tests
There is always something, a bar to jump over, a hill to climb. These structures are set up to keep the lonely programmer coding away forever in thier basement. Imagine you write this awesome PSR compliant piece of software but you forgot to unit test every single feature using hard coded unit tests? GET OF OUT HERE! In some cases with the nature of OOP programming test driven development (TDD) will nearly double the code base. Worse yet when you are a lonely dev writing your own unit tests for software that no one uses. It's an endless cycle. Next thing they are going to mention is automated tests.
*Don't commit: node_modules, vendor, .vscode directoriesAlso follow PSR-12,
*don't have uncapitalized classes, there are a lot.
*Use fillable property so you don't have these massive assignments to your models.
*Also look into form requests.Your project controller has about 25 functions/routes, split these off into separate more specific controllers.
*Use constants or enums for things like your status, so you don't have ->status = 0, 1, 2, etc.
Point 1 is a github open source thing - use github follow these github rules. 2,3,4 are style choices that are being imposed on the programmer by a random stranger. Who knows if the author finds this style useful or more efficient? why should they change something that they spent X years coding to match an arbitrary coding style? Maybe he likes having 25 routes in his controller? Maybe he likes constants being constants. Rather than enums. Why send him down a rabbit hole of changes that dont matter? I think its a form of slavery as I mentioned before. There is always something you missed in the standard, something that you need to do.
I got a hammer, you got nails?
In this case this person just likes using INTs for money; they are invested in propagating this ideology. I don't know, maybe it works, maybe it doesn't. I am sure the unit tests will determine the best route. Either Way, what if the programmer likes string numbers?
It looks like fields in the database related to money are text fields. You might want to evaluate the available field types and pick something less generic.I was looking at the money fields because I was curious if the project used ints for money - to track everything in cents or a decimal for dollars and cents. If I were starting a fresh project it would be an int, but that is just my 2 cents (not my 0.02).
Build it and they will come
I am not sure what this person was getting at because the author definitely said the project was "new". But this is just another hurdle placed in front of the lonely dev. This is funny because it takes so long to create a OOP PSR proof of concept that it makes it difficult to secure a client AND then build it in reasonable time. So what tends to happen is that new programmers build solutions to problems hoping that someone will want to use it but once they show it to other programmers they get rewarded with sidequests to waste more of thier time.
Do you have any early-adopter users? Was it developed with any user involved? Thanks! Have you started using it yet? What were you doing before? How did it change your business?
[bu]You modern stack is not modern enough[bu]
lol, if it takes you 3 years to write the code on a platform that updates every six months you are always going to be chasing your tail. And people will tell you that you are behind knowing fully well that it is impossible to keep up with the churn of modern stacks. Churn produces new tutorials, articles, tweets, books, maintenance requests - there is a whole ecosystem of people who benefit from instability, changing numbers and upgrades.
How come you're on Laravel 8 and Tailwind 1.x?
Add this and I will like you
This is just another sidequest. This person is neither a potential client or a contributor to the code base. Why does this person exist? This person's job in life is to perpetuate memes on the internet. Tests are the thing that will make them happy and tell others about your excellent code that you spent years writing. There is always something you need to do to make them like you. And if you had already done it they wont say "congrats" or pat you on the back - all they will do is seek out the next poor soul on which to propogate thier meme.
Please add tests. I will never use any application or package that doesn't have tests because I lack confidence in the software. Tests are a great way to ensure that everything is working without the monotony of manual testing via a browser.
All these modern PHP apps must follow this OOP song and dance of autoloading and PSR. I know these trends are limited to echo chambers because if you apply them to dev environments outside of PHP you will quickly realise that much of it is busy work destined to be deprecated for the next thing which is handed down from up above. In the end this project will gather dust like the thousands of other PSR PHP projects on github, Littering the internet forever until its consumed by AI. It's a gigantic ball of code. Somewhere in this mess there might be a few nuggets that maybe worth the look but chances are there is nothing but a well crafted waste of time.
At present the code base has 8 stars. Maybe it will get 1000 stars by next year. Downloading the code results in a 77mb zip full of compressed text files which means that there are alot of tiny little files and sub projects. In fact its 26,990 Files, 4,619 Folders. 272mb in total. There are fakers, dummy classes, factories, listeners all sorts of PHP OOP mannerisms: In the end it doesn't matter how big the codebase is or what frameworks are in use.
permanent link. Find similar posts in Articles.
Comment list is empty. You should totally be the first to Post your comments on this article.