1

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).

1 Answer 1

2

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.

4
  • 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
    Commented Nov 29, 2011 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
    Commented Nov 29, 2011 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
    Commented Nov 29, 2011 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
    Commented Nov 29, 2011 at 13:04

Your Answer

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

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