PHPackages                             martinezdelariva/railway - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. martinezdelariva/railway

ActiveLibrary

martinezdelariva/railway
========================

v1.0(8y ago)7273[1 PRs](https://github.com/martinezdelariva/railway/pulls)MITPHP

Since Aug 5Pushed 4y ago1 watchersCompare

[ Source](https://github.com/martinezdelariva/railway)[ Packagist](https://packagist.org/packages/martinezdelariva/railway)[ RSS](/packages/martinezdelariva-railway/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Railway
=======

[](#railway)

[![Build Status](https://camo.githubusercontent.com/a7044f05b4584bf9c2630a9822173c8dda339e923041eae5c4416b2b8948d2cb/68747470733a2f2f7472617669732d63692e6f72672f6d617274696e657a64656c61726976612f7261696c7761792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/martinezdelariva/railway)

This library is based on a post from (Scott Wlaschin)\[\] in order to bring Railway Oriented Programming to PHP.

Installation
------------

[](#installation)

Install it using [Composer](https://getcomposer.org/)

```
composer require martinezdelariva/railway

```

Motivation
----------

[](#motivation)

Typically every use case receives a request and produces a response. The use case passes for several steps until gets the final response to be returned. Handle every error scenario could be tedious and difficult to read.

Either
------

[](#either)

In order to have a type that works with any workflow, we borrow the type `Either` from functional programming:

[![Either](doc/images/either.png)](doc/images/either.png)

This object acts as a **switch**, where *left* means failure and the *right* means success.

Railway Naming Convention
-------------------------

[](#railway-naming-convention)

> Railways have switches ("points" in the UK) for directing trains onto a different track. We can think of these “Success/Failure” functions as railway switches.

- One track function: it has 1 input and 1 output.

[![One track](doc/images/one_track.png)](doc/images/one_track.png)

- Two track function: it has 2 input (`Either`) and 2 output (`Either`).

[![Two track](doc/images/two_track.png)](doc/images/two_track.png)

- Switch: it has 1 input and 2 output (`Either`).

[![Switch](doc/images/switch.png)](doc/images/switch.png)

Functions
---------

[](#functions)

Please find below the list of functions which connects switch together:

### Map

[](#map)

**1-1 : 2-2**

Converts one track function into two track function.

[![Map](doc/images/map.png)](doc/images/map.png)

### Lift

[](#lift)

Converts one track function into switch.

**1-1 : 1-2**

[![Lift](doc/images/lift.png)](doc/images/lift.png)

### Bind

[](#bind)

Converts switch into two track function.

**1-2 : 2-2**

[![Bind](doc/images/bind.png)](doc/images/bind.png)

### Unite

[](#unite)

Join two switches into another switch.

**1-2 and 1-2 : 1-2**

[![Unite](doc/images/unite.png)](doc/images/unite.png)

### Tee

[](#tee)

Dead-function to one track function.

[![Tee](doc/images/tee.png)](doc/images/tee.png)

### TryCatch

[](#trycatch)

Handling exceptions. Convert one track function into switch.

**1-1 : 1-2**

[![Try Catch](doc/images/try-catch.png)](doc/images/try-catch.png)

### Plus

[](#plus)

Combines switch functions in parallel.

**1-2 + 1-2 : 1-2**

[![Plus](doc/images/plus.png)](doc/images/plus.png)

### DoubleMap

[](#doublemap)

Handles both tracks, converting one track into two track function.

**1-1 : 2-2**

[![Double Map](doc/images/double-map.png)](doc/images/double-map.png)

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3202d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1567749?v=4)[José Luis Martínez de la Riva Manzano](/maintainers/martinezdelariva)[@martinezdelariva](https://github.com/martinezdelariva)

---

Top Contributors

[![martinezdelariva](https://avatars.githubusercontent.com/u/1567749?v=4)](https://github.com/martinezdelariva "martinezdelariva (3 commits)")

---

Tags

functional-programmingrailwayrailway-oriented-programmingfunctionalrailwayrailway-oriented-programming

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/martinezdelariva-railway/health.svg)

```
[![Health](https://phpackages.com/badges/martinezdelariva-railway/health.svg)](https://phpackages.com/packages/martinezdelariva-railway)
```

###  Alternatives

[lstrojny/functional-php

Functional primitives for PHP

2.0k7.3M48](/packages/lstrojny-functional-php)[nikic/iter

Iteration primitives using generators

1.1k5.9M38](/packages/nikic-iter)[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

15511.5M30](/packages/magento-magento2-functional-testing-framework)[lambdish/phunctional

λ PHP functional library

3612.0M23](/packages/lambdish-phunctional)[ihor/nspl

Non-standard PHP library (NSPL) - functional primitives toolbox and more

381368.5k](/packages/ihor-nspl)[qaribou/immutable.php

Immutable, highly-performant collections, well-suited for functional programming and memory-intensive applications.

344146.0k](/packages/qaribou-immutablephp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
