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
+60-7Lines changed: 60 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ The incoming web request will be handled by `your_app_domain` + whatever you put
21
21
22
22
To get an overview of all functionalities this package offers, you can check the `tests/PipeRequestTest.php`.
23
23
24
-
**Handling Pipes**
24
+
### Handling Pipes
25
25
26
26
Pipes are matched by the keys and values of the request's data attributes.
27
27
@@ -67,14 +67,67 @@ If you want to handle multiple requests with different attribute keys you can us
67
67
Pipe::any('{bar}', 'SomeController@index');
68
68
```
69
69
70
-
**Other Options**
70
+
### Other Options
71
71
72
-
// todo
72
+
**alias()**
73
+
Sometimes user might have a typo in their message or you simply want to have different cues available to trigger a Pipe.
73
74
74
-
-`alias()`
75
-
-`namespace()`
76
-
-`key()`
77
-
-`where()`
75
+
```php
76
+
Pipe::any('bar', 'FooBarController')
77
+
->alias(['ba', 'b-r', 'bas']);
78
+
```
79
+
80
+
The `FooBarController` will now be called upon `ba`, `b-r`, `bas` or as originally intended on `bar`.
81
+
82
+
**namespace()**
83
+
As you have probably noted the `routes/pipes.php` file is bound to a namespace configurable in the `config/pipes.php`. If you want to define a group with a different namespace, you can use the `namespace()` method:
84
+
85
+
```php
86
+
Pipe::middleware('pipe')
87
+
->namespace(config('pipes.namespace'))
88
+
->group(function () {
89
+
// define your namespaced pipes here
90
+
});
91
+
```
92
+
93
+
**key()**
94
+
Like demonstrated in the first section of the *Handling Pipes* documentation, you can define Pipe routes in man different ways.
95
+
96
+
```php
97
+
Pipe::match('foo', 'bar', function () {});
98
+
99
+
// same as
100
+
Pipe::match('foo:bar', function () {});
101
+
```
102
+
103
+
There is a third option to specify the `key` of a Pipe by using the `key()` method.
104
+
105
+
```php
106
+
Pipe::key('foo')->match('bar', function () {});
107
+
```
108
+
109
+
The key method is handy if you have got several pipe routes which reacts to the same key.
110
+
111
+
```php
112
+
Pipe::key('text')
113
+
->group(function () {
114
+
// all pipe definitions within here will check for the `text` as key in the incoming request
115
+
Pipe::match('some-text', function () {});
116
+
});
117
+
```
118
+
119
+
**where()**
120
+
To further specify which request should be send to a specific handler you can define conditions on each pipe, like you are used to with [Laravel routes](https://laravel.com/docs/5.8/routing#parameters-regular-expression-constraints).
0 commit comments