-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: generate one package from few wsdl #220
Comments
My point of view is that you can generate the packages in the same directory with the same main namespace then namespace each microservice under the main namespace such as:
Would it match your needs? |
In this case, I have to run the And also manually edit |
Indeed, this can seem overaded but this is the way as it is now. You composer.json file does not have to change for each update as only the main namespace, MyMicroServices, has to be defined within it as every package should be a sub namespace MyMicroServices\MicroService1, MyMicroServices\MicroService2, etc... |
I still do not understand with what parameters the generator should be called to get such a structure. |
My usercase. I generate packages via With a bunch of microservices, the problem of creating many small repositories, generating packages, publishing, and require. Too much fuss. It would be very convenient to be able to generate one large package with several such microservices. |
From my point of view, you would need to create one git project containing all the generated package under the same namespace and then require this unique dependency from your other project. I currently do this soort of thing using a PHP script (also possible with a command line script): $rootDir = dirname(__DIR__).'/public_html';
require_once $rootDir.'/vendor/autoload.php';
use WsdlToPhp\PackageGenerator\ConfigurationReader\GeneratorOptions;
use WsdlToPhp\PackageGenerator\Generator\Generator;
// define all my WSDL and their package destination
$wsdls = [
$rootDir.'/wsdl/provider1/service1/service.wsdl' => [
'src' => $rootDir.'/src/ProviderService/Provider1/Service1/',
'ns' => 'ProviderService\Provider\Service1',
],
$rootDir.'/wsdl/provider1/service2/service.wsdl' => [
'src' => $rootDir.'/src/ProviderService/Provider1/Service2/',
'ns' => 'ProviderService\Provider\Service2',
],
$rootDir.'/wsdl/provider1/service3/service.wsdl' => [
'src' => $rootDir.'/src/ProviderService/Provider1/Service3/',
'ns' => 'ProviderService\Provider\Service3',
],
$rootDir.'/wsdl/provider2/service1/service.wsdl' => [
'src' => $rootDir.'/src/ProviderService/Provider2/Service1/',
'ns' => 'ProviderService\Provider2\Service1',
],
// etc.
];
// clean existing files, avoid having not useful files anymore
exec('rm -rf '.$rootDir.'/src/ProviderService/Provider1/Service1/');
exec('rm -rf '.$rootDir.'/src/ProviderService/Provider1/Service2/');
exec('rm -rf '.$rootDir.'/src/ProviderService/Provider1/Service3/');
exec('rm -rf '.$rootDir.'/src/ProviderService/Provider2/Service1/');
// loop over each WSDL and generate its package
foreach ($wsdls as $wsdl => $settings) {
// Options definition: the configuration file parameter is optional
$options = GeneratorOptions::instance();
$options
->setOrigin($wsdl)
->setDestination($settings['src'])
->setNamespace($settings['ns'])
// ->setSoapClientClass(SoapClientBase::class)
->setStandalone(false) // no composer.json needed
->setGenerateTutorialFile(false) // no tutorial.php filke needed
->setSrcDirname(''); // no src folder needed for the generated package
// Generator instanciation
$generator = new Generator($options);
// Package generation
$generator->generatePackage();
fwrite(STDERR, PHP_EOL.$settings['src'].' / '.$settings['ns']);
} Within the composer.json file, I put: "autoload": {
"psr-4": {
"ProviderService\\": "src/ProviderService"
}
}, I then use any service from the |
@mikaelcom thank! This way looks good. |
I made my own fully automated solution to generate the final composer package, ready to commit, without any manual corrections. Hope this will help to someone:
It will produce the structure like:
The composer.json file will look like:
Please tell me what do you think about my solution. I'm looking forward to comments. |
I reworked my previous solution for automatic generation of the Composer package with a multiple WSDL services. It works exactly the same and makes the same folder and namespace structure. But now the generation script is a part of this package. It makes easier to regenerate the code if something changed in the future, because no need to search the script that generated this package maybe several years ago. You start creating Composer package with running this command in an empty folder of new Composer package:
It will make a simplest
Now your package is ready to commit and publish. Later you can run this script again to make sure all is up-to-date. |
Hi! One vendor provides its services as microservices. Approximately 20 microservices with 1-2 methods. Separate wsdl for each service.
It doesn't seem like a good idea to generate 20 packages for each service and include 20 dependencies.
I would like to be able to generate 1 package from an unlimited number of wsdl.
The text was updated successfully, but these errors were encountered: