{"id":36317689,"url":"https://github.com/martinezdelariva/railway","last_synced_at":"2026-01-11T11:05:04.264Z","repository":{"id":47606097,"uuid":"97965232","full_name":"martinezdelariva/railway","owner":"martinezdelariva","description":null,"archived":false,"fork":false,"pushed_at":"2021-08-22T09:17:48.000Z","size":511,"stargazers_count":7,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-10T09:36:17.024Z","etag":null,"topics":["functional-programming","railway","railway-oriented-programming"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/martinezdelariva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-21T16:01:43.000Z","updated_at":"2021-07-17T15:48:18.000Z","dependencies_parsed_at":"2022-09-06T06:52:18.887Z","dependency_job_id":null,"html_url":"https://github.com/martinezdelariva/railway","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/martinezdelariva/railway","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinezdelariva%2Frailway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinezdelariva%2Frailway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinezdelariva%2Frailway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinezdelariva%2Frailway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinezdelariva","download_url":"https://codeload.github.com/martinezdelariva/railway/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinezdelariva%2Frailway/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28301473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T08:21:30.231Z","status":"ssl_error","status_checked_at":"2026-01-11T08:21:26.882Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["functional-programming","railway","railway-oriented-programming"],"created_at":"2026-01-11T11:04:59.466Z","updated_at":"2026-01-11T11:05:04.242Z","avatar_url":"https://github.com/martinezdelariva.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Railway\n\n[![Build Status](https://travis-ci.org/martinezdelariva/railway.svg?branch=master)](https://travis-ci.org/martinezdelariva/railway)\n\nThis library is based on a post from (Scott Wlaschin)[https://fsharpforfunandprofit.com/posts/recipe-part2/] in order to bring Railway Oriented Programming to PHP.\n\n## Installation\n\nInstall it using [Composer](https://getcomposer.org/)\n\n\n    composer require martinezdelariva/railway \n\n## Motivation\n\nTypically 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. \n\n## Either\n\nIn order to have a type that works with any workflow, we borrow the type `Either` from functional programming:\n\n![Either](doc/images/either.png) \n\nThis object acts as a **switch**, where _left_ means failure and the _right_ means success.  \n\n## Railway Naming Convention\n\n\u003e 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.\n\n- One track function: it has 1 input and 1 output.\n\n![One track](doc/images/one_track.png) \n\n- Two track function: it has 2 input (`Either`) and 2 output (`Either`).\n\n![Two track](doc/images/two_track.png)\n \n- Switch: it has 1 input and 2 output (`Either`).\n\n![Switch](doc/images/switch.png)\n \n## Functions\n\nPlease find below the list of functions which connects switch together:\n\n### Map\n\n**1-1 : 2-2**\n\nConverts one track function into two track function.\n\n![Map](doc/images/map.png) \n\n\n### Lift\n\nConverts one track function into switch.\n\n**1-1 : 1-2**\n\n![Lift](doc/images/lift.png) \n\n### Bind\n\nConverts switch into two track function.\n\n**1-2 : 2-2**\n\n![Bind](doc/images/bind.png) \n\n### Unite\n\nJoin two switches into another switch.\n\n**1-2 and 1-2 : 1-2**\n\n![Unite](doc/images/unite.png) \n\n\n### Tee\n\nDead-function to one track function.\n\n![Tee](doc/images/tee.png) \n\n### TryCatch\n\nHandling exceptions. Convert one track function into switch.\n\n**1-1 : 1-2**\n\n![Try Catch](doc/images/try-catch.png) \n\n### Plus\n\nCombines switch functions in parallel.\n\n**1-2 + 1-2 : 1-2**\n\n![Plus](doc/images/plus.png) \n\n\n### DoubleMap\n\nHandles both tracks, converting one track into two track function.\n\n**1-1 : 2-2**\n\n![Double Map](doc/images/double-map.png) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinezdelariva%2Frailway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinezdelariva%2Frailway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinezdelariva%2Frailway/lists"}