Welcome Guest, Not a member yet? Register   Sign In
Multiple applications, shared models/libraries/views
#1

[eluser]avanwieringen[/eluser]
I finally subscribed to this forum, after reading a lot Smile

I recently (2 months ago) started learning the CodeIgniter framework and I think it is really awesome. I have 5 years of experience as a self-taught PHP-developer. As a test case I rebuilt the custom-made CMS from my work to CodeIgniter in simply 2 full working days, in the process implementing the Zend_ACL. This convinced me and my boss to transfer everything we have in websites to CodeIgniter. This is great, since it allows me to rewrite and optimize a lot of code that is really old or inefficient and in the process document it, since I will be leaving there in 1 year.

However, I have trouble to work out the basic setup and don't want to be faced with double work, double updating of documents etc.

Here is our setup:
Code:
- main website
  * www.company.nl
  * www.company.co.uk
  * in the future maybe others
- online survey system
  * www.company.nl/enquetes (enquetes = surveys in dutch)
  * www.company.co.uk/surveys (in the future possibly, but this could be simply a routes.php trick)
  * implements ACL
  * uses main website views
- customer portal
  * portal.company.nl
  * implements ACL
  * uses main website views
- project websites
  * project.company.nl
  * implements ACL
- backend for everything (website, surveys, portals, project websites)
  * admin.company.nl
  * implements ACL
  * needs the content-models / survey-models of the website / project / pwebsites etc

As you can see, everything has more or less something in common with each other. And here is my problem.

The ACL is easily solvable by putting it in the CodeIgniter systems folder making it accessible for all other applications. This can also be done with other shared libraries. However, for models and views this does not work. As far as I know CodeIgniter has no need to search the systems folder for models and views. And that means that I have to write several models and views that do essentially the same, which is not optimal.

In fact I have 4 different applications and 1 CodeIgniter base:
Code:
- applications
  |- website
     |- surveys
  |- customer
  |- project
  |- backend

- system
  |- libraries
     |- shared  
        |- ACL

The ACL-part is solved this way. But the others not.

The other thing I thought of was making 2 applications and using 1 system as follows:
Code:
- applications
  |- website
     |- main website
     |- surveys
     |- portal
     |- backend
  |- project

- system
  |- libraries
     |- shared  
        |- ACL

But this way it is hard for the backend to obtain the project-models and libraries. Which I want.

The last option was to put everything under 1 application but that way project-website, which is really completely different from everything else and has in fact little to do with it is contained in one application together with all others, while its in fact another application. I don't know if that's optimal for the future. And I dont know if its easy to use project.company.nl while it's in fact www.company.nl/project. The only connection between the project website and the rest is that the ACL defines which project-website-parts people can see.

Has anyone any tips? I know this is a big chunk of text, but I don't know the best solution. Smile
#2

[eluser]TheFuzzy0ne[/eluser]
First of all, you should not ever need to change anything in the system directory (unless of course it resides within the application directory). Your Zend directory should be in ./system/application/libraries. You can also extend the Loader class for loading Zend libraries if you so desire.

If you have more than one application, I'd suggest having a separate copy of Zend for each. It will take up a bit more space, but it should be much easier for you to change at a later date if you want, without it having a knock-on effect with the rest of your apps. If you wanted to give several clients a business card, you'd give them a copy each. You wouldn't expect them to share the business card between them, would you?
#3

[eluser]Dam1an[/eluser]
An easy solution is to use symbolic links to point to a common directory for all your models and views
#4

[eluser]TheFuzzy0ne[/eluser]
That was going to be my next suggestion Tongue But I still think that could cause problems when multiple apps share code that could potentially change. Instead of having to fix one app, you'd have to fix four.
#5

[eluser]avanwieringen[/eluser]
Thanks for the answers! I will remove ACL from the Systems map and I will try symbolic links I think. However, if anything changes I have to change 4 apps, but that is a consequence of shares libraries/models/views.
#6

[eluser]Dam1an[/eluser]
The reason I suggested sym links was so that if you discover a bug, you only need to change it in one place, as soon as you start adding application specific functionality, you should extends the common one
#7

[eluser]avanwieringen[/eluser]
Yup, that was my idea also. Symbolic links solve most of the problem. It keep it flexible and maintainable.
#8

[eluser]Dam1an[/eluser]
You should implement this the same way CI does, so when you load one of your libraries/models/helpers/views, it will first check in the application specific directories, then in the shared directory, and finally in the core (only for libraries and helpers)




Theme © iAndrew 2016 - Forum software by © MyBB