WsdlToPhp / PackageGenerator

Generates a PHP SDK based on a WSDL, simple and powerful, WSDL to PHP
https://providr.io
MIT License
422 stars 73 forks source link

No autoload.php generated #206

Closed CnczubehoerEu closed 3 years ago

CnczubehoerEu commented 4 years ago

I used the following code, to generate PHP classes from a WSDL file:

// Options definition: the configuration file parameter is optional
        $options = GeneratorOptions::instance(/* '/path/file.yml' */);
        $options
            ->setOrigin('https://cig.dhl.de/cig-wsdls/com/dpdhl/wsdl/geschaeftskundenversand-api/3.0/geschaeftskundenversand-api-3.0.wsdl')
            ->setDestination('/var/www/public/tmp/DHL')
            ->setComposerName('yyy/DHL')
            ->setNamespace("DHL");
// Generator instantiation
        $generator = new Generator($options);
// Package generation
        $generator->generatePackage();

Only the folder "src" and the file "tutorial.php" is generated, but no autoload.php or vendor folder. Did I miss something?

Additional, I added the following line in the composer.json being part of the main project: ""DHL\": "Libraries/DHL/src"" in the psr-4 section.

However, still the error "Class 'DHL\ClassMap' not found" appears. I'm using PHPStorm => so I'm quite sure, that the pathes itself are correct. I have the feeling, I missed one or more steps?!

Thank you very much in advance for your help!

Best regards, Tobias

mikaelcom commented 4 years ago

Normally, the vendor directory, the composer.json and composer.lock files are created if the standalone option is set to true, which is the default behaviour.

So you should ensure that this option is set to true or that you don't have any error regarding the composer behaviour.

CnczubehoerEu commented 4 years ago

Thank you very much for your prompt help. I changed my code:

// Options definition: the configuration file parameter is optional
        $options = GeneratorOptions::instance(/* '/path/file.yml' */);
        $options
            ->setOrigin('https://cig.dhl.de/cig-wsdls/com/dpdhl/wsdl/geschaeftskundenversand-api/3.0/geschaeftskundenversand-api-3.0.wsdl')
            ->setDestination('/var/www/public/tmp/DHL')
            ->setComposerName('yyy/DHL')
            ->setNamespace("DHL")
            ->setStandalone(true);
// Generator instantiation
        $generator = new Generator($options);
// Package generation
        $generator->generatePackage();

No vendor directory, no autoload.php is created. Only DHL/src/.... Some additional ideas, which I can try? Thank you again for your help!

mikaelcom commented 4 years ago

Using the dockerized version of the project, I succeded to generate the SDK including the vendor directory after adding -dmemory_limit=-1 resulting in this command line:

docker exec -it package_generator php-7.2 -dmemory_limit=-1 .samples/dhl.php

With .samples/dhl.php containing the same code as yours:

<?php

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

use WsdlToPhp\PackageGenerator\ConfigurationReader\GeneratorOptions;
use WsdlToPhp\PackageGenerator\Generator\Generator;

$options = GeneratorOptions::instance(/* '/path/file.yml' */);
$options
    ->setOrigin('https://cig.dhl.de/cig-wsdls/com/dpdhl/wsdl/geschaeftskundenversand-api/3.0/geschaeftskundenversand-api-3.0.wsdl')
    ->setDestination(__DIR__.'/dhl')
    ->setComposerName('yyy/DHL')
    ->setNamespace("DHL");
// Generator instantiation
$generator = new Generator($options);
// Package generation
$generator->generatePackage();

I added -dmemory_limit=-1 as I had this error:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1179648 bytes) in /var/www/vendor/composer/composer/src/Composer/Json/JsonFile.php on line 270
CnczubehoerEu commented 4 years ago

I get no error messages. My PHP script runs cleanly. There seems to be enough memory. Could you please run it again with PHP7.3? I don't think it should make a big difference, but who knows? Thanks a lot!

mikaelcom commented 4 years ago

Same result with PHP 7.3 in my dockerized version.

Try writing the package generator state to a file dhl_generator.json like this:

file_put_contents('dhl_generator.json', json_encode($generator, JSON_PRETTY_PRINT));

Share the result through Gist or by email at github@mikael-delsol.fr

kenod commented 4 years ago

I have the same issue. No autoload file or vendor dir created. Only directory SRC and tutorial.php

mikaelcom commented 4 years ago

@CnczubehoerEu and @kenod: I just created the feature/issue-206 branch which contains debug messages about composer feature, could you try with this branch and tell me what's happening ?

mikaelcom commented 4 years ago

Any progress?

The phar file can also be downloaded from either http://phar.wsdltophp.com/wsdltophp-feature-issue-206-php7.phar or http://phar.wsdltophp.com/wsdltophp-feature-issue-206-php5.phar

Err0r404 commented 4 years ago

Not sure if related but I also cannot get vendor directory.

Here is the error in console :

php .\wsdltophp-php7.phar generate:package --urlorpath="https://ws.chronopost.fr/rdv-cxf/services/CreneauServiceWS?wsdl" --destination="./chronofresh" --composer-name="my-bundle/chronofresh" --force
 Start at 2020-06-15 07:34:48
Unable to locate a valid CA certificate file. You must set a valid 'cafile' option.
A valid CA certificate file is required for SSL/TLS protection.
You can disable this error, at your own risk, by setting the 'disable-tls' option to true.

In CaBundle.php line 133:

  [ErrorException]
  file_get_contents(phar://[REDACTED]/wsdltophp/wsdltophp-php7.phar/vendor/compose
  r/ca-bundle/src/../res/cacert.pem): failed to open stream: phar error: "vendor/composer/c
  a-bundle/res/cacert.pem" is not a file in phar "[REDACTED]/wsdltophp/wsdltophp-p
  hp7.phar"
mikaelcom commented 4 years ago

Not sure if related but I also cannot get vendor directory.

Here is the error in console :

php .\wsdltophp-php7.phar generate:package --urlorpath="https://ws.chronopost.fr/rdv-cxf/services/CreneauServiceWS?wsdl" --destination="./chronofresh" --composer-name="my-bundle/chronofresh" --force
 Start at 2020-06-15 07:34:48
Unable to locate a valid CA certificate file. You must set a valid 'cafile' option.
A valid CA certificate file is required for SSL/TLS protection.
You can disable this error, at your own risk, by setting the 'disable-tls' option to true.

In CaBundle.php line 133:

  [ErrorException]
  file_get_contents(phar://[REDACTED]/wsdltophp/wsdltophp-php7.phar/vendor/compose
  r/ca-bundle/src/../res/cacert.pem): failed to open stream: phar error: "vendor/composer/c
  a-bundle/res/cacert.pem" is not a file in phar "[REDACTED]/wsdltophp/wsdltophp-p
  hp7.phar"

Thanks for the tip, I just generated again the phar's online including the missing file, you can download it from the same links above

JeffHooper commented 3 years ago

I also have the exact same issue. Have spent several hours trying different configurations with no luck. All that generates for me is the src folder with its contents, and the tutorial.php file. No autoload.php.

mikaelcom commented 3 years ago

I also have the exact same issue. Have spent several hours trying different configurations with no luck. All that generates for me is the src folder with its contents, and the tutorial.php file. No autoload.php.

Can you paste the way you generate the package (including the WSDL url otherwise by email at contact@mikael-delsol.fr)? Did you try to use the specific phar file? Did you see any log output?

Sorry for this interrogatory :wink:

mikaelcom commented 3 years ago

Feel free to open back this issue if needed

cyrilperard commented 1 year ago

@mikaelcom hello, I have the same problem, no vendor folder and composer.json are generated when i generate the package.
PHP 7.4 and "wsdltophp/packagegenerator": "^3.4". An idea ?

mikaelcom commented 1 year ago

@cyrilperard did you try using the dedicated phar file from https://github.com/WsdlToPhp/PackageGenerator/issues/206#issuecomment-642667647?

Rom1906 commented 1 year ago

@mikaelcom hello ! I have the same problem with PHP 8.2.3 but the phar in the comment dosent' works. Many depracated returns errors. A solution please ?

mikaelcom commented 1 year ago

@Rom1906 can you give a try with http://phar.wsdltophp.com/wsdltophp-feature-issue-206-php82.phar?

Rom1906 commented 1 year ago

@mikaelcom when I try with the new phar I have an open file error. Maybe an error during download file ? Can you send it in a zip ?

mikaelcom commented 1 year ago

I had modiffied my script that generates the phar, which did not checked out the right branch :man_facepalming:, so the phar was not right anyway.

You should be able to download the phar http://phar.wsdltophp.com/wsdltophp-feature-issue-206-php82.phar.zip

Rom1906 commented 1 year ago

I had modiffied my script that generates the phar, which did not checked out the right branch 🤦‍♂️, so the phar was not right anyway.

You should be able to download the phar http://phar.wsdltophp.com/wsdltophp-feature-issue-206-php82.phar.zip

All seems all right, thanks !

mikaelcom commented 1 year ago

Then, is it working with the latest version of the project? Because I did not change anything to make it work :thinking:

Rom1906 commented 1 year ago

It 's working with the zip phar I downloaded this morning

mikaelcom commented 1 year ago

I mean with http://phar.wsdltophp.com/wsdltophp-php82.phar.zip for example? Thanks

Rom1906 commented 1 year ago

Yes with this file

mikaelcom commented 1 year ago

And do you have the autoload.php file generated under the vendor directory? As this is the issue here for some users.

Rom1906 commented 1 year ago

Yes ! It was too my problem with my default composer.phar image_2023_02_20T15_40_36_762Z