You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+44-3Lines changed: 44 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,10 @@ Configuration
31
31
];
32
32
// ...
33
33
```
34
-
After adding the bundle, you have a new factory service **phpflo** which uses a registry of all your accordingly tagged services.
34
+
After adding the bundle, you have a new factory service **phpflo.network** which uses a registry of all your accordingly tagged services.
35
+
Another possibility is to use **phpflo.network_di** service.
36
+
The difference between these services is: network uses a registry and components are registered **only once** and collected during compile time. This is useful when using the network within on request cycle and build it only once.
37
+
If you are working e.g. with a long running process, you should us the network_di where every component will be fetched as a fresh object from DIC for every network build.
35
38
You can add components using following steps:
36
39
37
40
**Component class**
@@ -61,9 +64,9 @@ class ReadFile extends Component
61
64
}
62
65
}
63
66
```
64
-
Keep in mind to exend the PhpFlo\Component or implement PhpFlo\ComponentInterface!
67
+
Keep in mind to extend the PhpFlo\Component or implement PhpFlo\ComponentInterface!
65
68
66
-
**service definition**
69
+
**service definition (phpflo.network)**
67
70
```yaml
68
71
# app/config/services.yml
69
72
@@ -77,6 +80,21 @@ services:
77
80
```
78
81
You can name the service whatever you want: The only two important things are the tags. It needs name "phpflo.component" to be found in compiler pass and the alias will be used as component name for the graph file.
79
82
83
+
**service definition (phpflo.network_di)**
84
+
85
+
```yaml
86
+
# app/config/services.yml
87
+
88
+
services:
89
+
app.read_file:
90
+
lazy: true
91
+
shared: false # force instantiation
92
+
class: AppBundle\Component\ReadFile
93
+
tags: # optional
94
+
- {name: phpflo.component, alias: read_file}
95
+
96
+
```
97
+
80
98
**graph file** (app/config/my_graph.json)
81
99
```json
82
100
{
@@ -143,6 +161,29 @@ You can name the service whatever you want: The only two important things are th
143
161
```
144
162
The builder will automatically search for the provided graph file in '''app/config''' - if you need subdirectories, you can provide the filename in the formate '''subdir/graph.json'''
145
163
164
+
**processes definition (network_di)**
165
+
```json
166
+
{
167
+
...
168
+
"processes": {
169
+
"ReadFile": {
170
+
"component": "app.read_file"
171
+
},
172
+
"SplitbyLines": {
173
+
"component": "split_str"
174
+
},
175
+
"CountLines": {
176
+
"component": "counter"
177
+
},
178
+
"Display": {
179
+
"component": "output"
180
+
}
181
+
},
182
+
...
183
+
}
184
+
```
185
+
Add the service name as component name!
186
+
146
187
Example
147
188
----
148
189
Within a symfony controller with access to the DIC, you can simply create a graph like this:
0 commit comments