We have a very large and complex application that uses Yii 1.x. We’re planning on moving to an Yii 2 backend with an Angular front end. So virtually all of our Yii 2 calls would return JSON objects only, and no views would be required.
It would be great if we could run the two versions of Yii in parallel, gradually replacing portions of the site as we can. We could use a URL distinction to switch between them. I think the only major issue would be sharing a session. Am I correct in that? Has anyone else done something like this? Any suggestions?
Yes I have a large project based on Yii 1.1 that runs my clients back-offie. On the same server I also have their front-end, which includes a significant amount of e-commerce, using Yii2. The two environments share the same databases.
So from a technical standpoint there is absolutely no reason why you can’t run both environments on the same server. But it sounds like you want to take it a step further and be able to jump from one environment to the other using a shared session. One way to do this is to store your session information in the database. (See http://www.yiiframework.com/doc-2.0/yii-web-dbsession.html for an example in Yii2 for how to do this). Doing it this way would make it available to both environments.
So, it must be possible to do it the other-way round. To include Yii1 as a vendor in a Yii2 project
The alternative, is to convert the parts of legacy Yii1 code that I need from the new Yii2 frontend into a service and call these with either XHTML or JSON returns. This could be as simple as adding if (Yii::app()->request->isAjaxRequest) to controller actions …
This would then make me wonder if I could make my entire frontend website into an AJAX app …