brpaz
brpaz

Reputation: 3658

Symfony2 using third party vendors inside a bundle

I am creating a CpanelBundle which will integrate the Cpanel xmlapi into Symfony. I will use the class provided by CpanelInc here: https://github.com/CpanelInc/xmlapi-php.

I want to make this bundle usable across projects and also open source.

The Symfony documentation says you should not put third party libraries into your bundles. The Cpanel class also don't have a namespace and its not on composer.

I could and should put the Cpanel class in vendor folder but how can I add it to autoload and to my bundle composer.json so when I release my bundle the user will also get it?

Upvotes: 0

Views: 980

Answers (1)

l3l0
l3l0

Reputation: 3393

Hello you can load this file using composer. Please see composer autoload documentation

Your composer.json can looks like:

{
    "name": "my/bundle",
    "autoload": {
       "psr-0": {"": "src"}
    },
    "require": {
         "php": ">=5.3.2",
         "symfony/framework-bundle": ">=2.1,<2.3-dev",
         "CpanelInc/xmlapi-php": "*"
    },
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "CpanelInc/xmlapi-php",
                "version": "master-dev",
                "dist": {
                    "url": "http://github.com/CpanelInc/xmlapi-php/zipball/master",
                    "type": "zip"
                },
                "source": {
                    "url": "git://github.com/CpanelInc/xmlapi-php.git",
                    "type": "git",
                    "reference": "master"
                },
                "autoload": {
                    "files" : ['xmlapi.php']
                }
            }
        }
    ]
}

Will be even better when you just create composer.json and add it for CpanelInc/xmlapi-php and do PR :)

Upvotes: 1

Related Questions