Download the PHP package sf4/wsdl-creator without Composer
On this page you can find all versions of the php package sf4/wsdl-creator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sf4/wsdl-creator
More information about sf4/wsdl-creator
Files in sf4/wsdl-creator
Package wsdl-creator
Short Description PHP WSDL creator using PHPdoc (annotations, reflections).
License MIT
Informations about the package wsdl-creator
PHP WSDL Creator
Introduction
WSDL creator allows generating WSDL documents based on PHP classes using annotations and reflection mechanism. This generator also give possibilty to generating overview methods and parameters with SOAP examples used in WSDL.
Support: >= PHP7.2.
Installation
To install wsdl-creator at your project use composer.
Create new project:
composer.phar create-project georgo/wsdl-creator myproject
or add to the composer.json file:
Configuration
To start working with creator you must create new WSDLCreator
object and define for him:
- class to generate
WSDL
SOAP
server location- documnet namespace.
SOAP
server must be created in location specified in WSDLCreator
.
To render XML
use method renderWSDL
. To properly load generator classes use composer loader which is in vendor/autoload.php
.
Full configutaion listing:
Now if we try call address http://localhost/wsdl-creator/ClassName.php?wsdl
you recive WSDL
document.
Define web service method
To define is a web service method you must use @WebMethod
annotation.
Simple type
Simple types are described here.
Usage
So you type @param
next type one of simple types (string
) after name of variable ($name
).
You can also use arrays
of the simple types.
Usage
In input parameter now you must define what type of array you pass (string[]
).
Example
SimpleTypeExample
Annotations
- @desc Method description
- @param type $varialbe_name
- @return type $return
Wrapper type
Wrapper types are user defined clases which you can generate WSDL
complex types.
Usage
You must define class User
with public fields and doc comments which contains field type as example:
This mechanism use reflection, i.e. User
class must be visible to the generated class - possible use namespaces (\Namespace\To\User
).
You can define arrays of wrappers.
Usage
This annotation will generate array of users.
Example
WrapperTypeExample
Annotations
- @desc Method description
- @param wrapper[] @className=ClassName
- @return wrapper @className=\Namespace\To\ClassName
Object type
You can dynamically create object at runtime. Use object
parameter type.
Usage
This annotation create complex type with name
and age
elements.
Also you can wrapp classes in object.
Usage
Above example will return UserNameWithId
object which contains pointer to User
complex type and int
type.
Another option is creating array of objects.
Usage
This annotation creata array of objects with payment
and user
on each element of array.
Example
ObjectTypeExample
Additional info
In object
you can use array of wrappers and array of simple types.
Annotations
- @desc Method description
- @param object $object @type1=$name1 @type2=$name2
- @param object $object @(wrapper $nameWrapper @className=User) @type1=$name1
- @param object[] $object @type1[]=$name1
- @return
Service overview
You can generate service overview through renderWSDLService
method. This show all infos about method and parameters used in service with sample SOAP
request.
Example
Styles
By default, the WSDLCreator
will generate WSDLs using the rpc/literal binding style.
To specify rpc/encoded or a wrapped document/literal binding style, set the binding style on the WSDLCreator
object.
When specifying the wrapped document/literal binding style, you can use WSDL\DocumentLiteralWrapper
to automatically wrap the returning value in an appropriate wrapped object.