1

Let me preface this by saying that I am normally not a PHP developer, and am a complete beginner when it comes to Symfony2. I was kind of thrown into this project, and we are on a pretty tight deadline.

With that out of the way, here is my problem:

At my company, we have a PHP library for an internal API which is old; it doesn't use namespaces and it doesn't really follow any standard naming convention such as PSR-0 or PEAR. However, I need to use this in our Symfony2 project. Symfony2 obviously relies on namespaces a lot. Am I completely screwed if I don't update the library to follow the "new" conventions, or can I somehow use it anyway? The thing is, it is a pretty huge library, and we simply don't have time to do that right now (someone should have done it ages ago, but that is another topic...).

Theoretically, could I just place the lib under vendor/ and use good old old requires/includes in my bundles? Will this even work? Will I get a mob of angry Symfony/PHP developers after me by doing this?

Or, is there a better way that I'm not aware of?

07kro
  • 23
  • 3
  • Perfectly okay to do what you suggested. One of the core Symfony 2 framework libraries (Twig) is not namespaced. The only thing is that if your library has classes then you need to use \ClassName to refer to them. Here is an example: http://symfony.com/doc/current/cookbook/templating/twig_extension.html – Cerad Sep 03 '14 at 15:29
  • And if the library only has a few public facing entities then you might want to write a Symfony 2 bundle to act as an interface. That will make your application look modern. But it is not required. – Cerad Sep 03 '14 at 15:32

1 Answers1

2

You can do what you suggested, and you can even use the MapClassLoader, and give it a static map between your classes and your files, so that you don't even need to require files from your library. You don't have to write this map by hand, you can generate it with the class map generator

greg0ire
  • 22,714
  • 16
  • 72
  • 101