3

Thanks in advance for your help...

I come from a Java/Maven development environment and have been extremely familiar with Java dependencies and sharing common code using Maven.

I've recently moved to an organization that is PHP based. We have 3 different projects, all which have a shared code base. Up until now, the dev's have simply copy/pasted code from one project to another to keep the shared code in sync across projects.

Previously in the Java/Maven world, the shared code would be maintained in a separate project, and create a JAR. You would then "mvn install" that module, which would install that JAR in a local repository, and the project that needs that "dependency" would download it from your local repository, allowing for quick development of shared code AND the project using the shared code.

I've been looking for something similar in PHP and haven't been able to find it. I've found suggestions like Git submodules, PHARs and PEARs. But I'm seeing people complain about Git Submodules (https://softwareengineering.stackexchange.com/questions/158847/recommended-methodology-for-working-with-shared-libraries-and-mercurial), and our devs are saying that using PHARs and PEARs incredibly slow down dev efforts because they have to build the shared library before they can use the shared library (not to mention I can't find a accepted standard of "building" PHP).

Another option I've considered is having the shared code live "somewhere" on the file system and referencing the filesystem in code. This is unattractive to me because it makes the environment difficult to set up (imagine if you have a 5 common libraries, you have to check all 5 out just to get your code to work).

So my question is, what are people using to tackle this issue? Also please correct any assumptions I may have made above (re: PEARs, PHARs, PHP Building, etc)!

1 Answer 1

2

I think you should definitely look into Composer, sort of Maven for PHP projects.

Thats solves a lot of package management problems in PHP projects.

Sign up to request clarification or add additional context in comments.

3 Comments

Yea I've read about composer, and definitely looks intriguing! However, and correct me if I'm wrong) it looks like it uses packagist for a repository, but what about developing against a private or local repository? Thanks in advance for your help!
You can add private repositories to the composer.json so you can host all code internal getcomposer.org/doc/…
Awesome. Let me run this by my team and see what they think!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.