Using Cycle ORM

I’m considering Cycle ORM as one of supported database abstractions and implemented user storage in the yii-demo with it.

In the pull request I’ve used annotations (Doctrine-compatible) to describe schema. SQLite is used as storage engine.

Here’s comparison with Doctrine and Laravel’s Eloquent:

Features are described in docs:


Some reasoning would be appreciated - e.g.

  • why not to use Yii native ORM
  • comparison of Yii.2 ORM against other ORMs - propel, doctrine, Cycle … - features, pros, cons, performance bench.

It’s hard to take a standpoint just from one question / link and not many developers will have enough time to do in-depth analysis. This would be such a serious change that it would require kind of RFC draft & voting …

1 Like

You may confused PHP Project with Yii Project :stuck_out_tongue: . There are no RFC or voting rules in Yii.


Nothing is confused - read kind of RFC.
It was meant to suggest that there should be transparent process of accepting such a serious future decision rather than a decision of a 1-3 core developers.
I dont mean it in a bad way, but removing traditional built-in ORM influences whole community interested in Yii3 development (opencollective) - so everybody will depend on development of Cycle. Who is behind it? Will it be coordinated with Yii3 development? How about removing bugs? Adding new feature(s) ?
In PHP any new language feature requires RFC, which is voted 2/3 majority, as you know. If Yii2’s praised ORM should be dropped, there should be draft elaborated reasoning as to why, pros/cons, performance … and then voting yes or no. Otherwise Yii.3 is becoming just bunch of 3rd party libs, not genuine framework.


Where did you find information, that it will be dropped?

And who will be allowed to vote?

1 Like

With yii3 you can use any library including Active Record of Yii2, the point is that you have to migrate it and that will take time, you can contribute helping in the migration.

Who is behind it?

SpiralScout LLC, me personally.

Will it be coordinated with Yii3 development?


How about removing bugs? Adding new feature(s)?

All coordinated, bugs and features related to Yii will be put into priority.


Aha, thanx for explaining, let’s put it clear:

  • Yii’s built-in ORM / AR will NOT be dropped (still can be installed as a separate package), but can be replaced upon developer’s wish with Cycle ORM, or eventually other ORM - correct ?

  • syntax of Cycle queries looks pretty familiar to Yii’s ORM syntax at first sight, which may lower learning curve for legacy Yii coders. What would be reason(s) to use Cycle rather than Yii’s ORM ? Performance, features, code generator … etc?

1 Like

Here’s some extra info:

Yes. Yii will be able to work with any DBAL. Initially we have no resources to port Yii 2 AR over to Yii 3 but we may do so eventually.

@lubosdz I completely agree with your concerns and let me add my voice to you as well regarding AR ( change / drop / releasing Yii 3 without it for any reason) should be announced and introduced globally to the whole community and making sure there’s a real reason why it’ll not be included / replaced by another ORM.

Completely agree with you, @samdark I believe we’ve to distinguish between having Yii compatible with any library vs loosing the framework standards / spirit / and signature. Yii 3 IMHO should keep the spirit and signature of Yii and make sure we are not ending by having a group of libraries under one umbrella without guidance / standards that distinguished Yii in the last 10 years.

@samdark IMHO Yii 3 should not be released without having AR as the default ORM shipped. otherwise 99% of Yii developers will be forced to have dramatic changes that will lead to lose them trying the 3rd version of Yii, and will lead current Yii developers seek for a more sustainable / backward compatible framework.
I’m not against changing, and not against trying something simpler and better, but we’ve to make sure that the community is understanding the new changes especially when it touches a back-bone part in the framework like AR.

Regarding we don’t have resources to port Yii 2 AR to Yii 3, I can participate in this part, we can discuss it further to put requirements / deliverables, will be my pleasure for sure to contribute to my favorite framework.

Thanks for the contribution offer. AR works on top of DBAL layer so it could be ported first.

There are repositories for that:

I’d start with cleaning up yiisoft/db first.

There will be guidance in form of the definitive guide. Here’s the repository for work in progress:

It is going to include “working with Doctrine”, “working with Cycle” and, if AR will be implemented, working with AR.

Big changes would be needed anyway since Yii 3 changes a lot of core concepts aiming for easier maintenance and ability to structure projects better. That is major new version. That is supposed to break things and a lot. Maybe even more than it was between Yii 1 and Yii 2.

1 Like

Fresh docs from Cycle showing how to use it with Active Record pattern:


@samdark Interesting, so when we define an Interface we could switch between cycle orm and Yii AR

If that’s an interface for an entity / record — yes.