Symfony2/Composer use package

121 Views Asked by At

I'm trying to use the payone PHP-SDK from http://github.com/PAYONE/PHP-SDK/archive/master.zip
I included it in my composer.json like this:

"require": {
        "payone/php-sdk": "1.0.*"
    },
"repositories": [
            {
                "type": "package",
                "package": {
                    "name": "payone/php-sdk",
                    "version": "1.0.0",
                    "dist": {
                        "url": "http://github.com/PAYONE/PHP-SDK/archive/master.zip",
                        "type": "zip"
                    },
                    "autoload": {
                        "psr-0": { "Payone_": "php/" }
                    }
                }
            }
        ]

My question: How do I use it in my controller?

1

There are 1 best solutions below

1
On BEST ANSWER

Please note the PayOne SDK uses PEAR style classnames ( i.e. Vendor_Folder_Classname ) and not the PSR-0 convention with namespaces. pear style autoloading is compatible with composer's psr-0 autoloading.

Make sure you prefix the classnames with \ or add a use statement on top of your controller class. See igor's answer here.

To instantiate a new builder object use something like:

class MyController
{
    public function myAction()
    {
        $conig   = new \PayOne_Config(array(/* settings */));
        $builder = new \PayOne_Builder($config);

        // now use the builder            
    }

The PayOne_Autoload and PayOne_Bootstrap classes are only needed for setting up autoloading which is in your case handlded by composer.