sharing libraries across web projects sharing libraries across web projects codeigniter codeigniter

sharing libraries across web projects


Separate them into a module, and use something like composer.

http://getcomposer.org/

Or just put them in a separate SCM.


One thing you can do:

Put all the shared code in libraries, helpers and models and place this in a separate folder. Then use:

$this->load->add_package_path('shared location');

Also take a look here: http://codeigniter.com/user_guide/libraries/loader.html , under application packages.

This works for most of the stuff, except controllers.


Use version control! In svn you can use externals, git has submodules or subtrees.

You don't want to use hardlinks, you'll run into weird issues like updating one project influences another project ("that I haven't touched in weeks").

The code can be in two physical places but shared under version control. There will always be only one authorative copy, namely the one in your version system. All physical copies are derivatives. It's important to see that you have control over when you update the code of a specific project, so a change at one point doesn't immediately break another project in case you made a mistake.If you do want to catch these kinds of errors, set up a proper regression testing environment.

Sharing a development environment with another developer is also a big no. You don't want to have to wait till your colleague fixes a parse error that breaks the entire program. Each developer should have their own copy (checkout!) of a project and similarly each project should have their own copy (externaled) of shared code.