Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii Activerecord without yii

Can I use Yii's Activerecord (model) classes without Yii? It looks like it have lots of dependencies. I want to use ORM and Validation mechanism of Yii in my own project.

like image 798
Tahir Avatar asked Oct 21 '14 08:10

Tahir


3 Answers

Yii's ActiveRecord Classes have lots of dependent classes, hence you'll not be able to use only those classes. For every error you get you end up including all the dependent classes.

If you want to use the ORM for your project, then why don't you use some of the best ORMs available for PHP? And moreover you'll be 100% sure that nothing is broken.

Some of the PHP ORMs that you can use are:

  1. Propel
  2. PHPActiveRecord
  3. Doctrine
  4. Redbean

For more information, look at some of the following SO Questions:

  1. Good PHP ORM
  2. Redbean Vs Doctrine

Hope this helps.

like image 175
Vinod Tigadi Avatar answered Oct 22 '22 11:10

Vinod Tigadi


I will say better if you don't and write something your own by taking the idea from Yii or best will be use Yii itself, because CActiverecord is core part of Yii extending CModel and CComponent if you try to extract it from Yii you will find in the end that you copied almost everything.

like image 31
Kuldeep Dangi Avatar answered Oct 22 '22 10:10

Kuldeep Dangi


your question seems to be impossible to answer. You can't extract a PHP class from Yii without use the whole framework. Frameworks like Symphony, offers to you some components that you can use and don't need to use whole framework. There are a project ORM on PHP, I have never used it, but you can do a experience... http://www.phpactiverecord.org/ I hope it helps you, hugs.

like image 32
Programadores Brasil Avatar answered Oct 22 '22 12:10

Programadores Brasil