PHPackages                             functional-php/trampoline - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. functional-php/trampoline

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

functional-php/trampoline
=========================

Trampoline implementation for PHP.

1.1.0(9y ago)3517.7k↓50%31BSDPHPPHP &gt;=5.6.0

Since Oct 24Pushed 8y ago2 watchersCompare

[ Source](https://github.com/functional-php/trampoline)[ Packagist](https://packagist.org/packages/functional-php/trampoline)[ RSS](/packages/functional-php-trampoline/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (1)

Trampoline
==========

[](#trampoline)

[![Build Status](https://camo.githubusercontent.com/372fb687fe887014eb747e2416478fd6f59979090d0ace953c11494936b6d64e/68747470733a2f2f7472617669732d63692e6f72672f66756e6374696f6e616c2d7068702f7472616d706f6c696e652e737667)](https://travis-ci.org/functional-php/trampoline)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/825604990393e3b2f8a86a8772f6a9bcae94b0a7aeb0a34e1b7d687c5fa332c5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f66756e6374696f6e616c2d7068702f7472616d706f6c696e652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/functional-php/trampoline/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/5327f4f1d18bb0ddfa59146bd37603f90a1f2150d9262020fd163a400cfe9630/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f66756e6374696f6e616c2d7068702f7472616d706f6c696e652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/functional-php/trampoline/?branch=master)[![Average time to resolve an issue](https://camo.githubusercontent.com/173017c62f77e43ac37f1b55426ce6ff8b5c353a3747462d78df5e91d8dc3914/687474703a2f2f697369746d61696e7461696e65642e636f6d2f62616467652f7265736f6c7574696f6e2f66756e6374696f6e616c2d7068702f7472616d706f6c696e652e737667)](http://isitmaintained.com/project/functional-php/trampoline "Average time to resolve an issue")[![Percentage of issues still open](https://camo.githubusercontent.com/35a589ac72f2db3e34aeacf40d7718af4b3b4a9491c40195947776a2ef507a2f/687474703a2f2f697369746d61696e7461696e65642e636f6d2f62616467652f6f70656e2f66756e6374696f6e616c2d7068702f7472616d706f6c696e652e737667)](http://isitmaintained.com/project/functional-php/trampoline "Percentage of issues still open")[![Chat on Gitter](https://camo.githubusercontent.com/ef03cfbbd5ec62aaabc567543aab69fdf2c97d9efb7b8374d9aa2cef00a6d912/68747470733a2f2f696d672e736869656c64732e696f2f6769747465722f726f6f6d2f67697474657248512f6769747465722e737667)](https://gitter.im/functional-php)

Trampolines are a technique used to avoid blowing the call stack when doing recursive calls. This is needed because PHP does not perform tail-call optimization.

For more information about what is tail-call optimization (or TCO), you can read :

For a more in depth definition of trampolines and recursion as a whole, I can recommend you read  which is using Python but should be easy enough to understand.

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

[](#installation)

```
composer require functional-php/trampoline

```

Basic Usage
-----------

[](#basic-usage)

If we have the following recursive function:

```
