tags:

views:

28

answers:

3

Hello people, Im working on a few php based projects and im having an issue of having to maintain separate code bases with common code. The common code shared amongst all the projects is added physically (file are copied in the folder) and when a change is needed we have to manually replicate the fixes in the common code functionality in each project.

In java we can create a library (jar file) and share it among different projects. Is there any shared library related concept available in PHP 5.

+3  A: 

PHP's version of a jar is called Phar: http://php.net/manual/en/book.phar.php

Rob Olmos
A: 

Wouldn't it be easier to check the shared code into a version control repository, and check it out into the projects? For example, SVN supports that with the svn:externals property

Piskvor
+1  A: 

Although PHP now supports phar files, the right way to solve the problem is by using include files (and paths) effectively.

The include path is always searched in the same order for files - so a good practice is to to have 2 hierarchies defined, one for the scope of the code (e.g. everything, application, module) and one for the environment where it is running (holding such things as related URLs, batabase connections etc e.g. everything, environment (development / test / live), cluster node)

C.

symcbean