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).

  • I am confused as to what you are asking here. You seem to know what you are doing, but just want validation? If so, good job, this makes sense... except on the being a PHP dev part :P Jun 23, 2017 at 14:17
  • Thanks... that;s because of the available programmer pool here...
    – wmac
    Jun 23, 2017 at 14:59
  • 1
    It would help if you expressed what you hope this will achieve. Otherwise we just assume you're doing this for reasons and end up not being able to say no because we think the tools/techniques do exactly what you need because all we really know are the tools and techniques. Give us something that could be wrong for us to double check. Jun 23, 2017 at 15:57
  • I hope that using queries would be easier to understand (for mentioned reasons) to other developers, and take less time to figure how to do a complicated report or data grid (we have more than a hundred)... Speed is another concern... ORM seems more suitable for simple object relations
    – wmac
    Jun 24, 2017 at 9:05
  • We sometimes have relations between 10 tables...or even more in some reports
    – wmac
    Jun 24, 2017 at 9:06

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.