Wednesday, January 12, 2022

[FIXED] Yii2 app alongside CraftCMS utilizing YII2

Issue

Currently I have an app that is built INSIDE of CraftCMS plugins. I'm extracting these classes out and into an independent Yii2 framework.

How does Yii2 framework know WHEN to receive a request and process it? For example with Craft I am able to POST to /index.php?action=/ctrl/ctrlname/action&data=somedata but I'm unsure of how to do this with Yii?

I want to run CraftCMS and a separate Yii2 framework on the same server (for now) so JS will be making $.ajax() requests to the backend and I need CraftCMS to pick up certain ones and Yii2 to pick up other ones.


Solution

I decided to write a custom index.php file that would require_once $path where $path was the path to the correct app index.php file for bootstrapping.

This way in my custom index.php it would detect which app I wanted to load (based on a url component in the request) and then bootstrap appropriately.



Answered By - Exziled

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.