Dir structure and code reuse -> Best methods?

Hey all, I am converting our existing legacy procedural CRM to Yii.

I’ve already built out the tables and generated models, controllers/crud, but I have a question for best method to structure my files with Yii.

Currently, we have the structure of:

/var/www/dev/lib/ << shared code

/var/www/dev/crm.domain.com/public/ << doc root of CRM

/var/www/dev/www.domain.com/public/ << doc root of one-of-many additional domains representing our company

(Note that the path is /var/www/dev/, as we have dev, test, and prod environments)

What is the best way to keep a similar structure, preventing code duplication, and allowing each non-CRM domain to be able to read data from (and insert into) the CRM? I would like to have all CRM-related content to be subject to CRM-controlled rules, validation, etc, so that the www domains are just a content passthru.

I would like to see something like:


/var/www/dev/lib/base_crm_application/ << base crm app code

/var/www/dev/crm.domain.com/private/ << crm application extending from the base crm app

/var/www/dev/crm.domain.com/public/ << crm doc root (index.php and related files)

/var/www/dev/www.domain.com/private/ << www application extending the base crm app

/var/www/dev/www.domain.com/public/ << www doc root

Is this do-able? If so, implemented how?

Or, is there a better way to achieve the same goal?



Looks like this article solves my dilemma: