Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Let's says that I am creating a PHP library that is using PHP 5.3 and namespaces and my library requires another library to work (this case it is the sfYaml library). I am trying to think of the best way to include this library.

Is it considered good/acceptable practice to include the third party libraries directly in my code (assuming the license allows which sfYaml does) or is it better to not include the third party libraries and just have the user make sure the libraries are somewhere on their system and have them configure the path?

I mean that only issue I have had in the past with including that third party libraries in my libraries is that if the user also has the same library for their project, there would be issues with including it twice however now with PHP 5.3 and namespace, that is not an issue. I am just try to think if there are any other issues with including third party libraries directly in my code (with having them namespaced under my main namespace).

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

The main issue with redistributing a third party library with your code is licencing. You should make sure that:

  1. The third party library is licenced under a licence that allows redistribution,
  2. The third party library is licenced under a licence that allows modification,
  3. The licence of your code is not incompatible with the third party library licence.

Point 2 applies for the small changes to convert the third party library into your namespace hierarchy. Now you may assume that the MIT Licence, allows for all three points, but if you don't tell us your choice of licence we can't be certain.

If everything is fine with the licences, then I'd say it's a good practice to distribute all dependencies with your code. Users of your code may already have some of them, but you can't be sure which version they have. Better give users everything they'll need and everything you tested against, namespaces work wonders in those situations. You could have a \your_top_level_namespace\3rd_party namespace and put all dependencies under it.

share|improve this answer
    
Yea, my license is compatible with sfYaml's license assuming sfYaml is under the MIT license as would suggest based on the LICENSE file in the source code under version control (github.com/fabpot/yaml/blob/master/LICENSE). Thanks. –  ryanzec Nov 29 '11 at 12:39
    
Yeap, MIT is also listed as the library's licence on the webpage... They must have meant for the CC licence to be for the webpage itself, but they have it as an appendix to the lib's documentation. But since MIT is in the repo, it's MIT. I'm updating the answer... –  Yannis Rizos Nov 29 '11 at 12:43
    
I am probably going to be going with MIT myself, maybe BSD, bit I believe both are compatible with each other. –  ryanzec Nov 29 '11 at 13:03
    
If it doesn't make any difference to you, go with MIT, there's some debate on whether BSD and MIT are compatible –  Yannis Rizos Nov 29 '11 at 13:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.