Hacker News new | past | comments | ask | show | jobs | submit login

Some light weight ORMs do not require you to define all the properties ahead of time. They pull the field names from the table and generate the model record on the fly for you. This generally lets you prototype really fast. Laravel's Eloquent is known to do this. It's also useful for derived SQL fields when you use custom queries or join from other tables. Also kinda fun to do it for properties backed by a method. As in $record->isDirty will run isDirty() under the hood for you. All these things can be documented with PHPDoc and static analyzers handle it just fine.





Is it possible to dynamically define methods in PHP?

Yes.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: