3 ms·
Reading the code, this feels like a python developer writing PHP and frankly doing a bad job. Even the formatting seems to give up readability for line count fo
by ragnaruss 3y ago
Reading the code, this feels like a python developer writing PHP and frankly doing a bad job. Even the formatting seems to give up readability for line count for some unknown reason. There is no typing, no following of PSR-2 in anyway, and things which make my static analysis tools very unhappy.
A single file API is not a bad idea, but this is a bad implementation.
- onli 3y agoIt's a PHP project. It shouldn't have typing, that's for playing make-belief of writing in Java for the framework-oo-enterprise world. Psr-2 is often not followed, even in really good projects. And the static analysis tools are of limited use for a small code base (though to use them and make using them easier would be a plus).
- smarkov 3y ago> It's a PHP project. It shouldn't have typing, that's for playing make-belief of writing in Java for the framework-oo-enterprise world. At least types are enforced at runtime. Wait until you learn about TypeScript.
- askonomm 3y agoYes it definitely should have types, as is the standard in the community nowadays. Types are definitely not make-belief, as they are checked during runtime, making them actual, real types. I'd say any real project (not a prototype) that has more than 1 person working on it should definitely make use of types so that everyone would know what the shape of the expected data is.
- onli 3y agoTypes are not make-belief, I know that :) I said using them in a php project is playing make-belief, it's a joke about php developers coding enterprise Java style (for php salaries ofc). Had nothing to do with how the language handles types when they are used.
- askonomm 3y agoThat's true, modern PHP is eerily similar to Java, though the enterprise-ness of it is just an indication of not-great developers overcomplicating things (both in Java and PHP). As far as salaries go though, there's some very low ones (WordPress etc) and some very high ones, like Java senior level salaries as well, but I guess Java itself doesn't have so very low ones, which brings the average Java salary much higher than PHP.
- hparadiz 3y agoThis is how I write my controllers these days. https://github.com/hparadiz/technexus/blob/release/src/Controllers/Admin.php https://github.com/hparadiz/technexus/blob/release/src/Contr... Strict types make things easier tbh.
- manbitesdog 3y agoAuthor here. I haven't made up my mind yet about whether types speed up or down the development in small projects, and I don't know if it defeats its purpose a bit. This is actually one of the open topics in the direction of oink.php: https://github.com/jcarlosroldan/oink/issues/3 https://github.com/jcarlosroldan/oink/issues/3
- onli 3y agoFwiw, please don't take my comment as a strong opinions against types in such a project. I just try not to judge projects negatively that decide not to use them, and I have a personal aversion to enterprisy code (whatever it is exactly), especially when it's heralded as the only true way, and even more especially if it overcomplicates formerly simple ecosystems, like what happened to parts of PHP.
- notpushkin 3y ago> this feels like a python developer writing PHP Any particular reason other than uhhhh... 4 spaces? This doesn't seem particularly Python-esque to me either.
- ragnaruss 3y agoThe naming styles, the structure of the logic, the single line if statements with ternary returns, the lack of "use", the globals. Altogether it just gave me a clear feeling of this isn't a person who has written a lot of modern PHP but has probably written a lot of python.
- huqedato 3y agoProbably you consider "modern PhP" is just OOP, right ?
- ragnaruss 3y agoNo, I don't. I consider modern PHP being fully typed in all places possible, tests, clear and readable code, avoid globals, and avoiding clever tricks like reflection to extract function names to autowire up routes. The reality is this is a fun toy, and great job to the developer to making it work, but presenting it as anything but that is silly. There is very little benefit to using this over individual functional php files, and certainly more foot-guns.
- huqedato 3y agoSeems you don't like or understand the functional programming. Being OOP is very odd to think otherwise. I know how it feels now, after 5 years of programming in Elixir. I've been there...