Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
352 additions
and
131 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_site |
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 @@ | ||
pipeline.thephpleague.com |
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,8 @@ | ||
# Path to project specific favicon.ico, leave blank to use default | ||
favicon: | ||
|
||
# Path to project specific apple-touch-icon-precomposed.png, leave blank to use default | ||
apple_touch: | ||
|
||
# Path to project logo | ||
logo: |
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,4 @@ | ||
Getting Started: | ||
Introduction: '/' | ||
Installation: '/installation/' | ||
Usage: '/usage/' |
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,5 @@ | ||
title: Pipeline | ||
tagline: Composable sequental operations | ||
description: Pipeline Pattern implementation for PHP. | ||
google_analytics_tracking_id: | ||
base_href: https://pipeline.thephpleague.com/ |
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,102 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
{% if page.url == '/' %} | ||
<title>{{ site.data.project.title }} - {{ site.data.project.tagline }}</title> | ||
{% else %} | ||
<title>{{ page.title }} - {{ site.data.project.title }}</title> | ||
{% endif %} | ||
{% if site.data.project.description %} | ||
<meta name="description" content="{{ site.data.project.description }}"> | ||
{% endif %} | ||
{% if site.data.project.base_href %} | ||
<base href="{{ site.data.project.base_href }}"> | ||
{% endif %} | ||
{% if site.data.images.favicon %} | ||
<link rel="icon" type="image/x-icon" href="{{ site.data.images.favicon }}" /> | ||
{% else %} | ||
<link rel="icon" type="image/x-icon" href="https://theme.thephpleague.com/img/favicon.ico" /> | ||
{% endif %} | ||
{% if site.data.images.apple_touch %} | ||
<link rel="apple-touch-icon-precomposed" href="{{ site.data.images.apple_touch }}"> | ||
{% else %} | ||
<link rel="apple-touch-icon-precomposed" href="https://theme.thephpleague.com/img/apple-touch-icon-precomposed.png"> | ||
{% endif %} | ||
<link rel="stylesheet" href="https://theme.thephpleague.com/css/all.css"> | ||
</head> | ||
<body> | ||
|
||
<section class="all_packages"> | ||
<a href="https://thephpleague.com/"> | ||
<img src="https://theme.thephpleague.com/img/loep_logo.png" width="195" height="200" alt="The League of Extraordinary Packages"> | ||
</a> | ||
<h2>Our Packages:</h2> | ||
<ul> | ||
<!-- Loaded via JavaScript --> | ||
</ul> | ||
</section> | ||
|
||
<header> | ||
<a class="logo" href="/"> | ||
{% if site.data.images.logo %} | ||
<span class="icon"> | ||
<img src="{{ site.data.images.logo }}" width="50" height="40" alt="{{ site.data.project.title }} - {{ site.data.project.tagline }}"> | ||
</span> | ||
{% endif %} | ||
<span class="name">{{ site.data.project.title }}</span> | ||
<span class="tagline">{{ site.data.project.tagline }}</span> | ||
</a> | ||
<a href="https://thephpleague.com/" class="league"> | ||
Presented by The League of Extraordinary Packages | ||
</a> | ||
</header> | ||
|
||
<input type="checkbox" id="menu"> | ||
<label for="menu" onclick> | ||
<div class="closed">☰ Menu</div> | ||
<div class="open">☰ Hide Menu</div> | ||
</label> | ||
|
||
<main> | ||
<menu> | ||
{% for section in site.data.menu %} | ||
<h2>{{ section[0] }}</h2> | ||
<ul> | ||
{% for link in section[1] %} | ||
<li {% if page.url == link[1] %}class="selected"{% endif %}> | ||
<a href="{{ link[1] }}">{{ link[0] }}</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% endfor %} | ||
</menu> | ||
<article> | ||
{{ content }} | ||
</article> | ||
</main> | ||
|
||
<footer> | ||
<span>© Copyright <a href="https://thephpleague.com">The League of Extraordinary Packages</a>.</span> | ||
<span>Site design by <a href="https://reinink.ca">Jonathan Reinink</a>.</span> | ||
</footer> | ||
|
||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | ||
<script src="//theme.thephpleague.com/js/scripts.js"></script> | ||
<script src="//theme.thephpleague.com/js/prism.js"></script> | ||
|
||
{% if site.data.project.google_analytics_tracking_id %} | ||
<script> | ||
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]= | ||
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date; | ||
e=o.createElement(i);r=o.getElementsByTagName(i)[0]; | ||
e.src='//www.google-analytics.com/analytics.js'; | ||
r.parentNode.insertBefore(e,r)}(window,document,'script','ga')); | ||
ga('create','{{ site.data.project.google_analytics_tracking_id }}');ga('send','pageview'); | ||
</script> | ||
{% endif %} | ||
|
||
</body> | ||
</html> |
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,43 @@ | ||
--- | ||
layout: default | ||
permalink: / | ||
title: Introduction | ||
--- | ||
|
||
# League\Pipeline | ||
|
||
[![Maintainer](https://img.shields.io/badge/author-@shadowhand-blue.svg?style=flat-square)](https://twitter.com/shadowhand) | ||
[![Author](https://img.shields.io/badge/author-@frankdejonge-blue.svg?style=flat-square)](https://twitter.com/frankdejonge) | ||
[![Build Status](https://img.shields.io/travis/thephpleague/pipeline/master.svg?style=flat-square)](https://travis-ci.org/thephpleague/pipeline) | ||
[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/thephpleague/pipeline.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/pipeline/code-structure) | ||
[![Quality Score](https://img.shields.io/scrutinizer/g/thephpleague/pipeline.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/pipeline) | ||
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) | ||
[![Packagist Version](https://img.shields.io/packagist/v/league/pipeline.svg?style=flat-square)](https://packagist.org/packages/league/pipeline) | ||
[![Total Downloads](https://img.shields.io/packagist/dt/league/pipeline.svg?style=flat-square)](https://packagist.org/packages/league/pipeline) | ||
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/44ebfc4c-0e97-4b47-925e-b17de7ddce4f/mini.png)](https://insight.sensiolabs.com/projects/44ebfc4c-0e97-4b47-925e-b17de7ddce4f) | ||
|
||
## Introduction | ||
|
||
This package provides a plug and play implementation of | ||
the Pipeline Pattern. It's an architectural pattern which | ||
encapsulates sequential processes. When used, it allows you | ||
to mix and match operation, and pipelines, to create new | ||
execution chains. The pipeline pattern is often compared | ||
to a production line, where each stage performs a certain | ||
operation on a given payload/subject. Stages can act on, | ||
manipulate, decorate, or even replace the payload. | ||
|
||
If you find yourself passing results from one function to | ||
another to complete a series of tasks on a given subject, | ||
you might want to convert it into a pipeline. | ||
|
||
## Goals | ||
|
||
* Provide an implementations of the Pipeline Pattern. | ||
* Be highly composable. | ||
* Be immutable. | ||
|
||
## Questions? | ||
|
||
This package was created by [@frankdejonge](https://twitter.com/frankdejonge), currently maintained by [@shadowhand](https://twitter.com/shadowhand). | ||
|
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,13 @@ | ||
--- | ||
layout: default | ||
permalink: /installation/ | ||
title: Installation | ||
--- | ||
|
||
# Installation | ||
|
||
The recommended way to install this package, is through composer. | ||
|
||
~~~bash | ||
composer require league/pipeline | ||
~~~ |
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,99 @@ | ||
--- | ||
layout: default | ||
permalink: /usage/ | ||
title: Usage | ||
--- | ||
|
||
# Using League\Pipeline | ||
|
||
## Basic Example | ||
|
||
~~~php | ||
use League\Pipeline\Pipeline; | ||
|
||
class TimesTwoStage | ||
{ | ||
public function __invoke($payload) | ||
{ | ||
return $payload * 2; | ||
} | ||
} | ||
|
||
class AddOneStage | ||
{ | ||
public function __invoke($payload) | ||
{ | ||
return $payload + 1; | ||
} | ||
} | ||
|
||
$pipeline = (new Pipeline) | ||
->pipe(new TimeTwoStage) | ||
->pipe(new AddOneStage); | ||
|
||
// Returns 21 | ||
$pipeline->process(10); | ||
~~~ | ||
|
||
## Re-usable Pipelines | ||
|
||
Because the PipelineInterface is an extension of the StageInterface | ||
pipelines can be re-used as stages. This creates a highly composable model | ||
to create complex execution patterns while keeping the cognitive load low. | ||
|
||
For example, if we'd want to compose a pipeline to process API calls, we'd create | ||
something along these lines: | ||
|
||
~~~php | ||
$processApiRequest = (new Pipeline) | ||
->pipe(new ExecuteHttpRequest) // 2 | ||
->pipe(new ParseJsonResponse); // 3 | ||
|
||
$pipeline = (new Pipeline) | ||
->pipe(new ConvertToPsr7Request) // 1 | ||
->pipe($processApiRequest) // (2,3) | ||
->pipe(new ConvertToResponseDto); // 4 | ||
|
||
$pipeline->process(new DeleteBlogPost($postId)); | ||
~~~ | ||
|
||
## Pipeline Builders | ||
|
||
Because Pipelines themselves are immutable, pipeline builders are introduced to | ||
facilitate distributed composition of a pipeline. | ||
|
||
The PipelineBuilder's collect stages and allow you to create a pipelines at | ||
any given time. | ||
|
||
~~~php | ||
use League\Pipeline\PipelineBuilder; | ||
|
||
// Prepare the builder | ||
$pipelineBuilder = (new PipelineBuilder) | ||
->add(new LogicalStage) | ||
->add(new AnotherStage) | ||
->add(new LastStage); | ||
|
||
// Build the pipeline | ||
$pipeline = $pipelineBuilder->build(); | ||
~~~ | ||
|
||
## Exception handling | ||
|
||
This package is completely transparent when dealing with exception. In no case | ||
will this package catch an exception or silence an error. Exception should be | ||
dealt with on a per-case basis. Either inside a __stage__ or at time when the | ||
pipeline processes a payload. | ||
|
||
~~~php | ||
$pipeline = (new Pipeline) | ||
->pipe(function () { | ||
throw new LogicException(); | ||
}); | ||
|
||
try { | ||
$pipeline->process($payload); | ||
} catch(LogicException $e) { | ||
// Handle the exception. | ||
} | ||
~~~ |
This file was deleted.
Oops, something went wrong.
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.