vadimcomanescu / vmwarephp

Vmwarephp - vSphere API bindings for PHP
Other
76 stars 67 forks source link

Missing include for TypeDefinitions.inc with PSR0 #8

Open mattiasgeniar opened 11 years ago

mattiasgeniar commented 11 years ago

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

rgrwkmn commented 11 years ago

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.

mattiasgeniar commented 11 years ago

What configs did you give Composer to make this work?

rgrwkmn commented 11 years ago

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

ThreepE0 commented 7 years ago

thanks rgrwkmn, that worked for me after running composer update