Best practice for developing components shared by multiple applications

Hey all,

So here is a use case: I am writing two separate Yii applications, but there is a certain set of Model classes that I need both applications to share. Under normal circumstances, I would just build the two applications as their own modules. However, due to some unique constraints, differences in authentication and ACL approaches, and various performance/overhead issues, the two applications really need to be split into their own apps.

Is there a recommended best practice for maintaining a set of shared components between two applications? Should I place them into the actual yii framework directory structure somewhere, and then treat the shared components as their own project? (ie, have a version control project for App1, App2, and shared components).

I suppose it depends on what the components are, but generally if I have functionality that multiple projects can use, I’ll move it into an extension.

Putting it into the Yii Framework directory doesn’t seem like a good idea to me, but if you can find an alternate home for it, you could also, symlink to it if you don’t like keeping the two directories in sync.

For now I decided to put it into the framework dir as a dir called “shared”, and am managing that as a seperate project. Then for any project that needs the shared components I just call Yii::import(‘system.shared.mycomponentname.*’); This seemed like the most elegant solution to me. My deployment process for each site is then to deploy the framework folder, then the shared component folder, then the specific site folder.

Sounds like it gets the job done :)

I use modules from both Zend and Codeigniter Frameworks. These live in /protected/vendors/

You can put shared modules wherever you wish and simply copy the directory to your other applications and reference them appropriately.

If the modules were just 3rd party vendor code, that would be a fine solution, and is typically how I use those kinds of libraries. However, in this case, the shared components themselves are under constant development work, so trying to manage/synchronize that between multiple applications would become a real pain in the butt with that approach.