Skip to content

briandavidclark/ramuda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 

Repository files navigation

λ ramuda

Functional programming helper library for PHP based on Ramda.js

As far as I know, this is the most feature complete port of Ramda.js for PHP with over 350 functions. Also, includes many functions from Ramda Adjunct and Ramda Extension.

In addition, where possible, some of the functions have improved capabilities, such as filter and map handling strings and objects as well as the usual arrays.

Requires PHP 5.6 or higher.

Usage example:

use ramuda\R;

$users = [
   ['id'=>'45', 'fName'=>'Jane', 'lName'=>'Doe'],
   ['id'=>'22', 'fName'=>'John', 'lName'=>'Doe'],
   ['id'=>'99', 'fName'=>'John', 'lName'=>'Smith']
];

$listToSelect = R::pipe(
   R::filter(R::propEq('lName', 'Doe')),
   R::sortBy(R::prop('id')),
   R::map(function($x){
      return "<option value='{$x['id']}'>{$x['fName']} {$x['lName']}</option>";
   }),
   R::join(''),
   R::wrapWith(['<select>', '</select>'])
);

echo $listToSelect($users);

Produces the following string:

<select>
    <option value="22">John Doe</option>
    <option value="45">Jane Doe</option>
</select>

About

Functional programming helper library for PHP based on Ramda.js

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages