Thinking Functionally in PHP
Thinking Functionally in PHP
$25.00
Minimum price
$35.00
Suggested price
Thinking Functionally in PHP

This book is 100% complete

Completed on 2020-08-21

About the Book

Functional programming has a reputation of being too nerdy, academic, and inscrutable to be useful for "common" programmers. That reputation is only partially unearned, but the concepts behind functional programming are entirely within reach of every programmer in any modern language. That includes PHP. This book takes the reader through the basics of functional programming, the new capabilities of PHP 7.4 that make it even easier, and the computer-science-y underpinnings that make it all possible.

Computer scientists and software engineers tend to speak in entirely different languages, which is part of what makes learning more academic concepts difficult. This book offers both: Practical, applicable examples of how to leverage functional programming, category theory, and even the scary m-word. We start with the very basics and build up slowly, covering both the practical and theoretical just enough to be useful in everyday code.

About the Editor

Larry Garfield
Larry Garfield

Larry Garfield is an aspiring blacksmith who moonlights as Director of Developer Experience for Platform.sh.  When not trying to hand-forge his own medieval armory from scratch he tries to teach developers and development managers the skills of yesteryear that the industry has forgotten.

Table of Contents

  •  
    • Preface
    • Introduction
      • Functional vs. Procedural
      • Object-Oriented Code
      • Functional Style? Functional Language?
      • Type Systems
      • What to Expect
  • Part One
    • Pure Functions
      • Define “Pure”
      • Composing Functions
      • Binary Functions
    • First Class Functions
      • Anonymous Functions
      • Closure Objects
      • Short Lambdas
      • Object Binding
    • Memoization
    • Currying
    • Mapping
    • Filter
    • Reducing
    • Concatenation
    • Recursion
      • Recursion
    • Immutable Value Objects
      • What PHP Does
      • Making It Immutable
      • Objects, Functionally
      • Evolvable Objects
      • Dependencies
      • Entity Objects
      • Intra-Function Immutability
  • Part Two
    • Category Theory
      • What Is a Category?
      • Objects
      • Some Definitions
      • Structure
      • Let’s Get Meta
      • Isomorphism
      • Monoids
    • Categories in Code
      • Converting Structure
      • Function Objects
    • Fun With Functors
      • Combining Functors
      • Monads in Programming
      • Anatomy of a PHP Monad
    • Algebraic Data Types
      • Products
      • Product Types in PHP
      • Coproducts
      • Coproducts in PHP
  • Part Three
    • Handling Null
      • The Problem
      • The Example
      • The Category Theory Solution
      • The Programming Solution
      • An Alternate Implementation
      • A Note on Types
    • Either/Or and Error Handling
      • The Problem
      • The Example
      • The Category Theory Solution
      • The Programming Solution
      • Either Either?
    • Tracking Data
      • The Problem
      • The Example
      • The Category Theory Solution
      • The Programming Solution
    • Combining Monadic Behavior
      • The Example
      • The General Approach
      • Binding
      • The Lexers
      • Testing
      • Analysis
      • Being Lazy
  • Part Four
    • Features of Functional Languages
      • Auto-Currying
      • Recursion Optimization
      • Isomorphic Optimization
      • Function Composition
      • Function Naming
      • Generics
      • Callable Types
      • Comprehensions
      • Integrated Optionals
      • Optional Chaining
      • A Native Bind Operator
      • Enumerated Types
    • When to Go Functional
      • Avoid Global State
      • Make Pure Functions
      • Isolate IO
      • List Application
      • Embrace Value Objects
      • Embrace Functions as Values
      • Make Single-Method Callable Services
      • Think in Terms of Pipelines and Data Flow
      • Use Maybe and Either for Error Handling
      • Don’t Overdo It
    • Further Resources
      • Books
      • Videos
      • Papers

Authors have earned$9,411,989writing, publishing and selling on Leanpub,
earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub