klarna / php-xmlrpc

DEPRECATED: the klarna xmlrpc library for php
9 stars 13 forks source link

Use namespaces #5

Closed gildebrand closed 8 years ago

gildebrand commented 9 years ago

This library doesn't work very well to include into a namespaced project, since the library itself doesn't make use of namespaces. Our project uses Laravel, which can autoload libraries. However it can't autoload this library since it doesn't use namespace. Therefore we have to use functions like require to include the library, which doesn't look very good.

Is there any plan for refactoring this library to make use of namespaces, instead of putting it all in the global namespace?

keis commented 9 years ago

the rest api is where all the fun happens and there are no plans for any big refactoring of this code.

there is a fork that adds composer support I'm not sure if that's valuable for you https://github.com/Subscribo/klarna-invoice-sdk-wrapped

JoakimLofgren commented 9 years ago

This repo has composer support as well though.

keis commented 9 years ago

oops my bad

gildebrand commented 9 years ago

I don't know whether it's specified in Composer somehow, but I can't autoload the Klarna XMLRPC-library since it doesn't make use of namespaces (which the PSR-0 standard actually specifies as mandatory).

As far as I can see, this library doesn't support Composer autoloading. Am I wrong?

JoakimLofgren commented 9 years ago

So in a completely empty directory I do:

composer require klarna/php-xmlrpc

And then using the following index.php file:

<?php

require_once __DIR__ . '/vendor/autoload.php';

$k = new Klarna();
var_dump($k);

I can then run it:

$ php index.php 
class Klarna#2 (33)
...

Which shows that autoloading does work since I don't specifically require the Klarna class myself. You can also use classmaps instead of PSR-0 to make use of the composer autoloader.

JoakimLofgren commented 8 years ago

v5.0.0 implements namespaces.