Functional Programming in PHP, 2nd Edition

Write Concise, Maintainable, and Easier-to-test Code

Many languages have embraced Functional Programming paradigms to augment the tools available for programmers to solve problems. It facilitates writing code which is easier to understand, easier to test, and able to take advantage of parallelization. Functional Programming is a good fit for building modern, scalable solutions. Can you use functional programming in PHP?

PHP introduced anonymous function and closures in 5.3, providing a more succinct way to tackle common problems. More recent releases have added generators and variadics which can help write more concise, functional code. However, making the mental leap from programming in the more common imperative style requires understanding how and when to best use lambdas, closures, recursion, and more. It also requires learning to think of data in terms of collections for mapping, reducing, flattening, and filtering.

Functional Programming in PHP will show you how to leverage these new language features by understanding functional programming principles. With over twice as much content as its predecessor, this second edition expands upon its predecessor with updated code examples and coverage of advances in PHP 7 and Hack. Each chapter provides plenty of examples to illustrate each concept as it’s introduced and to show how to implement it with PHP. You’ll learn how to use map/reduce, currying, composition, and more. Finally, the book reviews the available external libraries and looks at new language features proposed for extending PHP’s functional programming capabilities.

Read a sample excerpt from the book

The sample includes the Table of Contents and Index.

Functional Programming in PHP Contents

This book covers the following topics in depth:

  1. History and Benefits of Functional Programming
  2. Language features including Types, Functions, Namespacing
  3. Using Recursion, Map, Reduce, and Filtering.
  4. How to use Memoization and Generators
  5. Helpful 3rd Party Libraries
  6. Functional Programming in HHVM’s Hack
  7. Functional Patterns including Composition, Partial Functions, and Pipelines
  8. Explanation of Pattern Matching, Functors, Applicatives, Monads, and Currying
  9. Implementation Examples
  10. Event Drive Programming

What others are saying

About the Author

Simon Holywell headshotSimon Holywell is a Senior Software Engineer at Aurion in Brisbane, Australia (http://aurion.com) and is passionate about web application development and motorcycles. His first public project was written with PHP 3, and since then, he has worked with every version of PHP and dabbled in Python, Scala, C, JavaScript, and more. He is also the author of of SQLStyle.guide and the ssdeep extensions for PHP’s PECL, Facebook’s HipHop Virtual Machine (HHVM), and MySQL.

See his blog and follow him on Twitter: @Treffynnon

Book Details

Title
Functional Programming in PHP, 2nd Edition
ISBN
978-1940111469
Pages
162
Digital Formats
PDF, ePub, Mobi
Author
Simon Holywell
Date Published
2016-10-26
Dimensions
7.5" x 9.2"
Language
English