-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from krakphp/0.4
Version 0.4
- Loading branch information
Showing
23 changed files
with
486 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
================= | ||
Custom Link Class | ||
================= | ||
|
||
You can optionally provide your own ``Link`` to allow easier access to the Context or other methods. It's best to extend the ``Mw\Link`` and just add methods and *not* data because the Link class logic is very critical to the design of the mw system. | ||
|
||
.. code-block:: php | ||
<?php | ||
use Krak\Mw; | ||
class LoggingLink extends Mw\Link | ||
{ | ||
public function echoLog($info) { | ||
echo $info . PHP_EOL; | ||
} | ||
public function log() { | ||
return $this->getContext()->logger; | ||
} | ||
} | ||
$handler = mw\compose([ | ||
function($i, $next) { | ||
$next->echoLog('hi'); | ||
return 1; | ||
} | ||
], null, null, LoggingLink::class); | ||
assert($handler(0) == 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
================= | ||
Pimple Middleware | ||
================= | ||
|
||
You can easily integrate your middleware stacks with pimple using the ``Mw\Context\PimpleContext`` which will allow any middleware to be a pimple identifier and give you access to your pimple container via the mw context. | ||
|
||
.. code-block:: php | ||
<?php | ||
use Krak\Mw; | ||
$container = new Pimple\Container(); | ||
$container['i'] = 5; | ||
$container['inc_mw'] = function() { | ||
return function($i, $next) { | ||
return $next($i + 1); | ||
}; | ||
}; | ||
$handler = mw\compose([ | ||
function($i) { return $i; }, | ||
function($i, $next) { | ||
$ctx = $next->getContext(); | ||
return $next($i + $ctx['i']); | ||
}, | ||
'inc_mw' | ||
], new Mw\Context\PimpleContext($container)); | ||
assert($handler(4) == 10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.