Using Laravel with DAO instead of Eloquent ORM

daolaravelorm

We have a complicated ERP software written in native PHP and our own micro-framework which uses big and complicated queries. We want to rewrite the application using an MVC framework (e.g. Laravel).

  • I have developed some other applications with Laravel and Eloquent and I think converting the queries of our ERP app into ORM form will bee very difficult and time consuming.

  • Furthermore I like a query based approach where related queries are gathered in DAO objects. The queries (even though complicated) are more straightforward than the ORM equivalents where the query logic is distributed in different places of model codes…

I want to see whether my approach makes sense:

  • I will convert the use of eloquent model files to DAO objects (and stop inheriting Eloquent).

  • I'll then use DAO objects (ex. model files) for data access (rather than entity objects).

Best Answer

I did the same work once (rewrite a PHP mini ERP from scratch) using Laravel, but instead of Eloquent, I used Doctrine (some strange things happened with the Eloquent query builder using SQL Server). Finally, I moved the entire codebase to Slim Framework and made an independent data access layer to handle complex queries the ERP had.

I think your approach is correct, if the data access layer is very complex to handle with Eloquent.