Skip to content

Commit e419990

Browse files
committed
Fix namespaces and classes uses in configuration examples and explanations #2
1 parent 6aaa480 commit e419990

File tree

1 file changed

+50
-45
lines changed

1 file changed

+50
-45
lines changed

saprfc-config.md

Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
PHP/SAP supports SAP remote system connection types A and B.
44

5-
* `phpsap\classes\Config\ConfigTypeA` configures connection parameters for SAP
5+
* `\phpsap\classes\Config\ConfigTypeA` configures connection parameters for SAP
66
remote function calls using a specific SAP application server.
7-
* `phpsap\classes\Config\ConfigTypeB` configures connection parameters for SAP
7+
* `\phpsap\classes\Config\ConfigTypeB` configures connection parameters for SAP
88
remote function calls using load balancing.
99

1010
The configuration classes implement the [JsonSerializable interface
@@ -22,7 +22,7 @@ as your editor supports auto-completion for classes loaded via composer.
2222
use phpsap\classes\Config\ConfigTypeA;
2323
//Create an empty configuration object of type A.
2424
$config = new ConfigTypeA();
25-
//ConfigCommon methods are inherited by ConfigTypeA
25+
//ConfigTypeA and ConfigTypeB common methods are in the CommonTrait
2626
$config->setAshost('sap.example.com')
2727
->setSysnr('999')
2828
->setClient('001')
@@ -46,13 +46,15 @@ Output
4646

4747
### Get a configuration from JSON
4848

49-
Of course the JSON encoded configuration is not a dead end. The class
50-
`phpsap\classes\Config\ConfigCommon` provides the method `jsonDecode($string)`
51-
for directly decoding a JSON encoded configuration into a configuration class.
49+
Of course the JSON encoded configuration is not a dead end. The trait
50+
`\phpsap\classes\Config\Traits\JsonDecodeTrait` provides the method
51+
`jsonDecode($string)` for the classes `\phpsap\classes\Config\ConfigTypeA` and
52+
`\phpsap\classes\Config\ConfigTypeB` which can be used to directly decode a JSON
53+
encoded configuration into a configuration class.
5254

5355
```php
5456
<?php
55-
use phpsap\classes\Config\ConfigCommon;
57+
use phpsap\classes\Config\ConfigTypeB;
5658
use phpsap\classes\Config\ConfigTypeA;
5759
//Let's assume the JSON encoded config from before.
5860
$jsonConfig = '{
@@ -63,89 +65,92 @@ $jsonConfig = '{
6365
"passwd": "password"
6466
}';
6567
/**
66-
* Let ConfigCommon determine the type of configuration
68+
* Let the JsonDecodeTrait determine the type of configuration
6769
* (A or B) of your formerly encoded JSON.
6870
*/
69-
$configA = ConfigCommon::jsonDecode($jsonConfig);
71+
$configA = ConfigTypeB::jsonDecode($jsonConfig);
7072
/**
7173
* You can always create an instance of your config
72-
* using already decoded arrays ...
74+
* using already decoded arrays.
7375
*/
7476
$anotherConfigA = new ConfigTypeA(json_decode($jsonConfig, true));
75-
// ... or objects.
76-
$stillConfigA = new ConfigTypeA(json_decode($jsonConfig, false));
7777
```
7878

7979
### Set configuration parameters.
8080

8181
You just learned that the constructor of the configuration classes accepts an
8282
array. Now nothing's holding you back to manually build the same array.
8383

84-
**All possible configuration parameters are constants of the respective
85-
configuration type.** That way you don't need to know their exact names, as long
86-
as your editor supports auto-completion for classes loaded via composer.
87-
8884
```php
8985
<?php
9086
use phpsap\classes\Config\ConfigTypeA;
91-
/**
92-
* ConfigCommon constants are inherited by ConfigTypeA.
93-
*/
87+
use phpsap\interfaces\Config\IConfigTypeA;
88+
use phpsap\interfaces\Config\IConfiguration;
89+
9490
$config = new ConfigTypeA([
95-
ConfigTypeA::JSON_ASHOST => 'sap.example.com',
96-
ConfigTypeA::JSON_SYSNR => '999',
97-
ConfigTypeA::JSON_CLIENT => '001',
98-
ConfigTypeA::JSON_USER => 'username',
99-
ConfigTypeA::JSON_PASSWD => 'password'
91+
IConfigTypeA::JSON_ASHOST => 'sap.example.com',
92+
IConfigTypeA::JSON_SYSNR => '999',
93+
IConfiguration::JSON_CLIENT => '001',
94+
IConfiguration::JSON_USER => 'username',
95+
IConfiguration::JSON_PASSWD => 'password'
10096
]);
10197
```
10298

10399
### Mandatory configuration parameters
104100

105101
**Type A:**
106102

107-
* `ConfigTypeA::JSON_ASHOST` The host name of a specific SAP application server.
108-
* `ConfigTypeA::JSON_SYSNR` The SAP system number.
103+
* `\phpsap\interfaces\Config\IConfigTypeA::JSON_ASHOST` The host name of a
104+
specific SAP application server.
105+
* `\phpsap\interfaces\Config\IConfigTypeA::JSON_SYSNR` The SAP system number.
109106

110107
**Type B:**
111108

112-
* `ConfigTypeB::JSON_MSHOST` The host name of the message server.
109+
* `\phpsap\interfaces\Config\IConfigTypeB::JSON_MSHOST` The host name of the
110+
message server.
113111

114112
**Common:**
115113

116-
* `ConfigCommon::JSON_CLIENT` The destination in RfcOpen.
117-
* `ConfigCommon::JSON_USER` The username to use for authentication.
118-
* `ConfigCommon::JSON_PASSWD` The password to use for authentication.
114+
* `\phpsap\interfaces\Config\IConfiguration::JSON_CLIENT` The destination in
115+
RfcOpen.
116+
* `\phpsap\interfaces\Config\IConfiguration::JSON_USER` The username to use for
117+
authentication.
118+
* `\phpsap\interfaces\Config\IConfiguration::JSON_PASSWD` The password to use
119+
for authentication.
119120

120121
### Optional configuration parameters
121122

122123
**Type A:**
123124

124-
* `ConfigTypeA::JSON_GWHOST` The gateway host on an application server.
125-
* `ConfigTypeA::JSON_GWSERV` The gateway server on an application server.
125+
* `\phpsap\interfaces\Config\IConfigTypeA::JSON_GWHOST` The gateway host on an
126+
application server.
127+
* `\phpsap\interfaces\Config\IConfigTypeA::JSON_GWSERV` The gateway server on an
128+
application server.
126129

127130
**Type B:**
128131

129-
* `ConfigTypeB::JSON_R3NAME` The name of SAP system.
130-
* `ConfigTypeB::JSON_GROUP` The group name of the application servers.
132+
* `\phpsap\interfaces\Config\IConfigTypeB::JSON_R3NAME` The name of SAP system.
133+
* `\phpsap\interfaces\Config\IConfigTypeB::JSON_GROUP` The group name of the
134+
application servers.
131135

132136
**Common:**
133137

134-
* `ConfigCommon::JSON_TRACE` The trace level, defined by the constants in
135-
`ConfigCommon`:
138+
* `\phpsap\interfaces\Config\IConfiguration::JSON_TRACE` The trace level,
139+
defined by the constants in `\phpsap\interfaces\Config\IConfiguration`:
136140
- `TRACE_OFF`
137141
- `TRACE_BRIEF`
138142
- `TRACE_VERBOSE`
139143
- `TRACE_FULL`
140-
* `ConfigCommon::JSON_CODEPAGE` Only needed it if you want to connect to a
141-
non-Unicode backend using a non-ISO-Latin-1 username or password. The RFC
142-
library will then use that codepage for the initial handshake, thus
143-
preserving the characters in username and password.
144-
* `ConfigCommon::JSON_LANG` The logon Language.
145-
* `ConfigCommon::JSON_DEST` The destination in RfcOpenConnection.
146-
* `ConfigCommon::JSON_SAPROUTER` If the connection needs to be made through a
147-
firewall using a SAPRouter, specify the SAPRouter parameters in the following
148-
format: `/H/hostname/S/portnumber/H/`
144+
* `\phpsap\interfaces\Config\IConfiguration::JSON_CODEPAGE` Only needed it if
145+
you want to connect to a non-Unicode backend using a non-ISO-Latin-1 username
146+
or password. The RFC library will then use that codepage for the initial
147+
handshake, thus preserving the characters in username and password.
148+
* `\phpsap\interfaces\Config\IConfiguration::JSON_LANG` The logon Language.
149+
* `\phpsap\interfaces\Config\IConfiguration::JSON_DEST` The destination in
150+
RfcOpenConnection.
151+
* `\phpsap\interfaces\Config\IConfiguration::JSON_SAPROUTER` If the connection
152+
needs to be made through a firewall using a SAPRouter, specify the SAPRouter
153+
parameters in the following format: `/H/hostname/S/portnumber/H/`
149154

150155
---
151156

0 commit comments

Comments
 (0)