5 ms·
Loved this article, those were all great points that I have faced on my daily job at a PHP shop. A breath of fresh air in amids of thousands of "ew, such a bad
by kingofthehill98 3y ago
Loved this article, those were all great points that I have faced on my daily job at a PHP shop.
A breath of fresh air in amids of thousands of "ew, such a bad language" and "a fractal of bad design", the latter being incredibly outdated and still referenced from time to time.
I love PHP, it was my first language and it's one hell of a productive ecosystem to be in. Laravel is an excellent choice for rapid prototyping and Symfony is probably one of the best web frameworks for enterprise projects. Paired with coroutines extensions such as Swoole/OpenSwoole/Swow it puts one hell of a fight performance wise with more modern languages.
- begueradj 3y agoI agree. Also Laravel is one of the best web frameworks for rapid prototyping :)
- bemusedthrow75 3y agoIndeed. Also, I have been looking for GraphQL implementations for other server-side languages recently and I have yet to encounter a schema-first implementation that comes close to what the Lighthouse layer for Laravel can do. That is really productive.
- aglione 3y agohave a look to http://strawberry.rocks http://strawberry.rocks for Python. I've still to find a better code first implementation too
- bemusedthrow75 3y agoThis is one I did look at and then forgot about -- thanks!
- withinboredom 3y agoWhy would you want to use graphql? In my experience, it’s pretty terrible for real-world use-cases.
- bemusedthrow75 3y agoLighthouse is sophisticated and productive. I only use it in fully-authenticated contexts but because it is schema-first with good ORM bindings and excellent annotation support, I barely write any logic that isn't a mutation, an accessor or a permissions gate. The occasional top-level query resolver. Beyond that it is the graphql schema and the models. And it gives me the opportunity to separate out the front end concerns in a way I could explain to someone else. Apollo has been a bit of a pickle on the front-end, mind you. That's a decision I'd revisit. But generally it has meant a flexible API interface and leads to nice low latency UIs. Check it out: https://lighthouse-php.com https://lighthouse-php.com And these really good third-party auth mutations for Passport: https://lighthouse-php-auth.com https://lighthouse-php-auth.com
- withinboredom 3y agoAh cool! I hadn't seen this before! I'd only seen fairly raw GraphQL from like 4-5 years ago, when you had to write your own auth, resolvers, deal with n+1 queries, etc. This is actually really nice and solves a lot of the issues I was thinking of.
- bemusedthrow75 3y agoRight. People keep telling me that code-first is better but there is no way all those complex APIs are easier to use than just spitting out some JSON from an endpoint. Schema-first feels more manageable. I'm not going to say I haven't had to do that a _bit_ here, when I've got into quite advanced things. (e.g. sometimes you might want to dynamically provide the values from an enum, or write your own decorators, or you might want a custom top-level resolver.) It's built on the WebOnyx reference implementation, so there's some help out there. But it's amazing how much code I haven't had to write, and being the sort of person I am with difficulties controlling focus, I absolutely love the schema-first approach. It interacts well with Eloquent scopes, with the ordinary API gate system, with policies and validations. It's actually weird how good it is. You still have all the same issues you have with GraphQL generally (like limiting graph traversals to things a user is authorized to see), but you have so many tools.
- viraptor 3y agoHuh? This article is talking about very similar issue to the fractal of bad design. Down to repeating specific ones like json_decode(null). Most of the fractal post still applies. The themes of surprises and consistency are strong in both. I agree that the language evolved since then, but the main categories are still not solved in the language. Nice frameworks just hide those well.
- bemusedthrow75 3y agoThe thing that I think PHP developers hate most about the Fractal of Bad Design article is hearing it from full-stack JS developers. They really do not have the moral high ground. PHP has improved since in a way that is rarely considered when reposting it, but JS has some deep language horrors of its own still, and many novel JS horrors like NPM have emerged largely since the Fractal article was published. As the King sang, so eloquently: o/~ clean up your own backyard o/~
- crabmusket 3y agoAs someone who writes PHP and JS professionally every day, I think they're leagues apart.* Sure, people love to look down on JS, but its fundamentals are much stronger than PHP's. PHP is no longer a terrible language- recent editions have made leaps and bounds on language features, and the ecosystem around Symfony is great. But on a weekly or monthly basis I run into something that makes me want to head-desk. JS's recent(ish) language improvements like `let` and ESM have been much more fundamentally significant than PHP's IMO, where we're still stuck with bad scoping and Java-brained class autoloading. *Not leagues apart in terms of productivity. I can certainly get a lot done with PHP. I mean leagues apart at their foundation, the basic concepts at work in the language. Most of that can be ignored until it rears up to harass you. Here's a great example of something similar to an issue that bit me last month: https://stackoverflow.com/q/3307409 https://stackoverflow.com/q/3307409
- rafark 3y ago> As someone who writes PHP and JS professionally every day, I think they're leagues apart. As someone who’s written a lot of php and JavaScript, I think the same thing but in the opposite way. JavaScript just can’t compare when it comes to designing a complex OO system.