Show HN: PHP API Bindings for Open Brewery DB (github.com)
Howdy! I'm a recent PHP convert after a decade of laughing at PHP memes on r/programmerhumor, and wanted to dive a bit deeper into the language by building something practical with it. I also love beer and decided to combine the two by building a PHP library for the Open Brewery DB API (https://openbrewerydb.org/). Hope someone finds it useful!
41 comments
[ 0.13 ms ] story [ 131 ms ] threadYou had an opportunity to help a php newb get better. Your comment even did the work to present the ways to improve the code. It’s all undercut by the tone, however, which really sounds like you’re just shitting on OP.
It would have been easier to just call out ways OP can improve than to shit on their work. Why take the extra effort to be mean?
The last line is also mean - you don’t need to diminish the scope for someone’s first project.
Was the purpose of your comment to help this person improve? Or to show your superiority? It came across as the latter but was so close to being really awesome if the negativity werent present.
I'm still fairly new to PHP, coming from the .NET/TypeScript world. Unfortunately, it wasn't ChatGPT generated and I'm well aware there's still a lot to learn. I'm always looking for ways to improve, so if you'd like to create a few issues, I'd be more than happy to address them and get the chance to dig deeper into PHP.
It can definitely be daunting putting something out into the wild for people to see, but I've found the constructive criticism (in most cases) that comes with the territory can only help improve whatever it is I'm working. Gotta take it all in stride.
Glad to have you join the community!
Is there an open database of beers/ratings similar to Untappd? Bar/brewery owners I know hate Untappd because of the exorbitant fees they charge.
The OPs code is quite readable and I wouldn't mind maintaining it (vastly better than the real-world legacy PHP code I have to maintain), but my main takeaway is "this is like Python with Java syntax" (interestingly the opposite of Kotlin, i.e. Java with Python syntax).
I'll be the first to admit I have a tendency to C#/Java-ify code in languages that I attempt to learn (could definitely argue it's a bad habit) due to nearly a decade of working with them. Any advice you might have to make things a bit more idiomatic to modern PHP? Always looking to improve the code however I can.
If you're aiming for this state of a codebase you'll lean heavily towards Object/Modular oriented styles which strongly resemble Java/C++ etc - even languages that express them in dramatically different manners (like OCaML) end up looking really familiar when built in a sustainable manner. There is a common visual expectation we have around code that promotes readability[1] and we'll form code in most languages to match that common visual expression. This is actually one reason I decidedly dislike python - since it's visual expression is encoded into the syntax evaluation of the language itself.
Anyways the TL;DR is that, IMO, clean maintainable code looks like clean maintainable code and the language only minorly impacts this appearance.
1. That isn't to say this is necessarily the best visual expression - it could just have been chosen early on and then just ingrained in us all.
There's a lot of this code also written in Python. However, I think Python's forced indentation and cleaner syntax is a boon because it makes bad code look bad and unreadable. Too often, variations in style conventions are used as a smokescreen for rubbish software.
and Java is same verbosity + has more mature (and arguably more performant) runtime + benefits of statically compiled language and rich library ecosystem?
what is selling point of PHP, that python and java don't fit into ?? (lets not even mention javascript/node with its runtime)
- the PSRs are pretty good & make the whole language seem like a good big framework
- php can actually be very fast nowadays
- decent type system (if you're unlike me any don't hate working with annotations, you'll be even happier)
- since php8 (especially 8.1 and 8.2) there were a lot of major new things (property promotion, named parameters)
On the contrary: - php.ini must die. It's not causing much issues for me anymore, but it just doesn't feel right.
I don't know why, but no matter how much i work in other languages, even if i really enjoy them (eg. go), nothing when starting from scratch for web server stuff, i always end up going with PHP. Whenever it's "just web" on the serverside, nothing beats php. Especially when you ignore the bad stuff and look at really well designed modern projects based on php8.
I just think it might be time to fork php8, start with a new name & get rid of all the old, dirty stuff that's still there for some weird & non-realistic backward compatibility.
If anyone is up for that task, i am happy to help & finance parts of that.
I just seem to be hater for no valid reason other than very personal things like: - hating the ini syntax - issues with module conflicts - how the overloading works
Might be my experience of annoyances when i didn't know the issues might be related to php.ini settings. And (still today), i only find out after googling issues like a moron.
I just have the feeling another solution might offer much better dev experience. But yeah, i can't offer any helpful insight here. Maybe it's just that i don't want to have to initialize at all, given that the PHP we talk about is not the one running on funny hardware, but rather purposefully configured servers anyway. But yeah, not sure what a better alternative would be right now without digging in to it.
but PHP code that consists of 30+ composers modules, each with 10+ classes with overengineered OOP crap does not encourage me to touch this code with a 10ft pole.
This has devolved into js type of crappy coding, and I can use JS for that, dont need PHP.
This is an important component to decoupling packages from specific underlying implementations like Guzzle.
You can even use the auto-discovery package to have whichever conforming HTTP client is installed (like Guzzle for example) be utilized, or allow via dependency injection an existing HTTP client to be passed in.
This would be a great enhancement since the PHP community has done a great job with these shared standards, it is a common expectation across packages to utilize them.