vadimcomanescu/vmwarephp

Missing include for TypeDefinitions.inc with PSR0

Opened this issue · 4 comments

It's been touched on on your blog as well: http://vadimcomanescu.wordpress.com/2013/03/19/vmwarephp-vsphere-api-bindings-for-php/comment-page-1/#comment-30

If you install \Vmwarephp via the following Composer:

{    
    "require": {
        "vmwarephp/vmwarephp": "dev-master"
    },
    "autoload": {
        "psr-0": {
            "Vmwarephp" : "vendor/vmwarephp/vmwarephp/library"
        }
    },
    "minimum-stability": "dev"
}

And you the try to use:

$vhost = new \Vmwarephp\Vhost(...);

you get the following error:

  [Vmwarephp\Exception\Soap]                                  
  Client: Class 'RetrieveServiceContentResponse' not found. 

I've solved it (ugly?) by including the necessary file within my usages:

require_once 'vendor/vmwarephp/vmwarephp/library/Vmwarephp/TypeDefinitions.inc';

After which it works. Could it be PSR0 autoloading isn't working as expected?

Also, the example in the readme for including the package in composer isn't working as I had to explicitly specify the PSRO autoloader to point to the correct 'libraries' directory - isn't the default naming either 'src' or 'lib'?

Let me know if I can help troubleshoot this further.

Thanks,
Mattias

I had the same problem with this and assumed I had done something wrong. I just told Composer where to find the classmap and since then haven't bothered trying to find out if there is another way this should work.

What configs did you give Composer to make this work?

Not sure why it wouldn't pick it up just by requiring it with composer, but I added the vmwarephp path to the classmap. Here is an example composer.json: https://gist.github.com/rgrwkmn/7254857

thanks rgrwkmn, that worked for me after running composer update