2
2
3
3
PHP/SAP supports SAP remote system connection types A and B.
4
4
5
- * ` phpsap\classes\Config\ConfigTypeA ` configures connection parameters for SAP
5
+ * ` \ phpsap\classes\Config\ConfigTypeA` configures connection parameters for SAP
6
6
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
8
8
remote function calls using load balancing.
9
9
10
10
The configuration classes implement the [ JsonSerializable interface
@@ -22,7 +22,7 @@ as your editor supports auto-completion for classes loaded via composer.
22
22
use phpsap\classes\Config\ConfigTypeA;
23
23
//Create an empty configuration object of type A.
24
24
$config = new ConfigTypeA();
25
- //ConfigCommon methods are inherited by ConfigTypeA
25
+ //ConfigTypeA and ConfigTypeB common methods are in the CommonTrait
26
26
$config->setAshost('sap.example.com')
27
27
->setSysnr('999')
28
28
->setClient('001')
@@ -46,13 +46,15 @@ Output
46
46
47
47
### Get a configuration from JSON
48
48
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.
52
54
53
55
``` php
54
56
<?php
55
- use phpsap\classes\Config\ConfigCommon ;
57
+ use phpsap\classes\Config\ConfigTypeB ;
56
58
use phpsap\classes\Config\ConfigTypeA;
57
59
//Let's assume the JSON encoded config from before.
58
60
$jsonConfig = '{
@@ -63,89 +65,92 @@ $jsonConfig = '{
63
65
"passwd": "password"
64
66
}';
65
67
/**
66
- * Let ConfigCommon determine the type of configuration
68
+ * Let the JsonDecodeTrait determine the type of configuration
67
69
* (A or B) of your formerly encoded JSON.
68
70
*/
69
- $configA = ConfigCommon ::jsonDecode($jsonConfig);
71
+ $configA = ConfigTypeB ::jsonDecode($jsonConfig);
70
72
/**
71
73
* You can always create an instance of your config
72
- * using already decoded arrays .. .
74
+ * using already decoded arrays.
73
75
*/
74
76
$anotherConfigA = new ConfigTypeA(json_decode($jsonConfig, true));
75
- // ... or objects.
76
- $stillConfigA = new ConfigTypeA(json_decode($jsonConfig, false));
77
77
```
78
78
79
79
### Set configuration parameters.
80
80
81
81
You just learned that the constructor of the configuration classes accepts an
82
82
array. Now nothing's holding you back to manually build the same array.
83
83
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
-
88
84
``` php
89
85
<?php
90
86
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
+
94
90
$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'
100
96
]);
101
97
```
102
98
103
99
### Mandatory configuration parameters
104
100
105
101
** Type A:**
106
102
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.
109
106
110
107
** Type B:**
111
108
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.
113
111
114
112
** Common:**
115
113
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.
119
120
120
121
### Optional configuration parameters
121
122
122
123
** Type A:**
123
124
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.
126
129
127
130
** Type B:**
128
131
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.
131
135
132
136
** Common:**
133
137
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 ` :
136
140
- ` TRACE_OFF `
137
141
- ` TRACE_BRIEF `
138
142
- ` TRACE_VERBOSE `
139
143
- ` 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/ `
149
154
150
155
---
151
156
0 commit comments