I want to replace the 2.x orm system by the new ORM before upgrading to CakePHP3. My app have several modules, at last about 100 tables. I prefer migrate the ORM in CakePHP2 rather than migrating everything at once.
Le mardi 22 septembre 2015 10:57:01 UTC+2, José Lorenzo a écrit :
It depends. The ORM can be installed as a standalone library already, what kind of integration are you looking after?
On Tuesday, September 22, 2015 at 9:23:50 AM UTC+2, Sulian Lanteri wrote:
Before migrate a big application in CakePHP3, I want first use the new ORM in this CakePHP 2.6 application, any idea how to do that (and/or a good example) ?
I don't get your problem guys. :) Add the new ORM via composer.
Just create the folders inside your 2.x app:
Make sure your autoloader is finding the classes based on their namespace and put your tables and entities in there just as you would do it in Cake3. Then use the TableRegistry instead of the ClassRegistry to get your table objects. Just the fact that Cake2 is not using newer php language features doesn't mean you can't use them. You can create and use traits within your app as well to make getting tables more easy for example.
BUT: If you're after a magic "convert all and everything" to the new ORM, this is not going to happen, you'll have to do it by hand.
The way we do it is to slowly migrate what we need, when we need it. So we'll slowly replace the old with the new ORM, they can co-exist. This way we get the fancy new ORM but can slowly migrate our app as we go.