But i fear this turns into some flame war about programming philosopy, so please let me add a disclaimer: i'm a very ignorant person, i'm not trying to convince anyone my way's the right way. However, for the sake of the thread's discussion, i'll answer them based on my experience. I obviously will have to think about this points (and i will). If you create a class on the fly, how would you do that? Your ORM objects are models if you're using an active record. Models are models whether it is an ORM or not.It works if you work alone, but not with a team. If you keep adding tables every single day from the start day to the end of your project, you have a serious issue with your design skill.It's always better to express what you want. Writing code is like writing an article or journal. If you create classes on the fly, people have to look at your code and read all of them to just find out what classes are being used. You're confusing future version of yourself and your team members.Even if you have to do "dump-autoload", how often do you really add a new model? The "models" directory is listed under "classmap" in the composer.json. You don't need to dump-autoload when you add a new model.How often do you really add a new table?.How often do you really change your table schema?.How hard is it to change your code to reflect changes in the table? We're not even dealing with a complex repository.I would not even think about trying your way because of a few reasons. If Eloquent is not the answer, maybe there's another way inside Laravel? Right now i'm adapting my own ORM/Model classes to Query Builder, but i would love to use some tool already there for the task. I don't want to keep on doing this if it's a known bad thing to do.Īnyway, i've been doing this with my own HORRIBLE orm classes, and now i'm working with Laravel (and i love it). So far, i've working like that for years and i'm very happy with the results of that approach. You think that's and "edge case", as in "almost wrong"? Please, if you may write it, i would love to read why. I want auto validation, atomic user permissions, common API, and automatic UI forms, for any action on any table on a selected DB, without me to having to code things like "$this->hasOne('stuff')" (or, worse, to create a class for that, and then having to dump-autoload it) when that's already stated in the table definition in the DB schema i want my ORM tool to read that already stated information and dinamically instantiate a ready-to-use class that i may subclass only if i need to. Basically, i want my CRUD fully automated, without having to code no trivial change on the DB schema anywhere in my classes. And that's how i ended here asking.Ībout sharing what i'm doing. And then i said to myself: "Oh no Canta! Stop it right there! You promised not to do this kind of things anymore!". Yup, that's exactly what i was thinking when i said "ugly hack".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |