Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code first Entity Framework model in PHP

I am recently working in a ASP.Net MVC project where we use code first technique to create all the database table. I really liked the idea, where you don't need to touch the database and create the model classes which are automatically mapped to the database by the EF layer.

I am planning to start a hobby project with PHP and was playing with Laravel (I am newbie in PHP). I was wondering if there is any equivalent framework in PHP that support code first pattern as EF 4.1?

I was looking into some Laravel tutorial, it looks like the ORM (eloquent) doesn't work exactly same way as the EF 4.1 in .net does. I seems to me that you still need to create the table in the database and then you create a model to map the database. Am I missing something?

Thanks.

like image 236
Pixelord Avatar asked Jan 06 '23 14:01

Pixelord


2 Answers

For PHP i suggest looking at Doctrine 2 as ORM. You define your Entities and doctrine will generate the classes and database structure for you.

like image 162
Michael Lantzen Avatar answered Jan 09 '23 03:01

Michael Lantzen


You may also look into ReadBeanPHP if you are going to write PHP from scratch. Not very feature-rich or beautiful, but it works :)

like image 26
vfsoraki Avatar answered Jan 09 '23 04:01

vfsoraki