4 ms·
You won't regret going the Yii route. I'm amazed that people are still coding the basics from the ground up when there are already top-notch frameworks out the
by AlexMuir 16y ago
You won't regret going the Yii route. I'm amazed that people are still coding the basics from the ground up when there are already top-notch frameworks out there.
- petervandijck 16y agoYii's approach of "create db first, then we create heaps of code for you" doesn't appeal to me at all...
- AlexMuir 16y agoOut of curiousity (and not snarky at all), what other approaches are there in the PHP world?
- jmathai 16y agoI guess I've never been interested in a framework building out classes based on my database tables so I'm not sure what the alternative approaches are. Is that what you meant? If you prefer than then I do think the larger frameworks are a good fit. What I'm saying is that I don't prefer that :).
- AlexMuir 16y agoI've got you, but I'm wondering what your approach is? I'm stuck in a mindset where I work from creating a database to CRUD to functional code.
- jmathai 16y agoI write the CRUD statements but only as I need them. For a lot of my tables I never intend on deleting records so a delete method never gets written. If I need to do a SELECT on a specific field(s) then I write that statement. It's usually a 4 line function in a class that deals primarily with that table (but not necessarily as it may make sense in a different class). I use static functions for that as well. class User { public static function getByEmail($email) { return getDatabase()->one('SELECT * FROM user WHERE email=:email', array(':email' => $email)); } } I don't typically end up with so many of those that it's unmanageable and writing it takes about 30 seconds. That's my approach. What's your thought on that coming from the mindset that a lot of that is taken care of by the framework? I'm curious since that's not a mindset I've had yet.
- gtcode 16y agoYii has Gii, which is a code generator that can be customized. Thus, the heaps of code can be created to your liking.
- jmathai 16y agoI'll check out Yii but if it does code generation on your behalf like the other commenter suggests then it's probably not going to appeal to me. The same could be said prior to Yii regarding building from the ground up. Yii shouldn't exist based on your own argument :).
- AlexMuir 16y agoThat's true I guess - it's just more of a community thing rather than build-your-own. I think I've seen three new PHP frameworks pass across the HN front page this week alone. But each to their own.