PHPackages                             tom-sapletta-com/phunc - 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. tom-sapletta-com/phunc

ActiveLibrary

tom-sapletta-com/phunc
======================

Functional Environment for PHP

078[1 issues](https://github.com/phunc-org/Phunc/issues)PHP

Since Jan 1Pushed 6y ago1 watchersCompare

[ Source](https://github.com/phunc-org/Phunc)[ Packagist](https://packagist.org/packages/tom-sapletta-com/phunc)[ RSS](/packages/tom-sapletta-com-phunc/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)DependenciesVersions (2)Used By (0)

[Phunc, functional programming in PHP with strong typing](https://github.com/phunc-org/Phunc)
=============================================================================================

[](#phunc-functional-programming-in-php-with-strong-typing)

The strongest side of PHP
-------------------------

[](#the-strongest-side-of-php)

With this libraries you are able to use benefits with strong typing in PHP 5 &amp; 7

- Collections with Data Models as Objects
- Units as Objects with Conversion between Units
- Calculator with all operations as Objects

[Apache2 requests](doc/Apache2.md)

introduction
------------

[](#introduction)

With Phunc library I share ideas practice software examples. "how to use simple functional PHP with usage objecting representation" utilities for functional programming.

Phunctional thinking
--------------------

[](#phunctional-thinking)

If you are not happy with functions in PHP to implements functional programming, try to use objects. PHP objects can help with:

- define
- transport
- conversion
- controlling

Example functional programming with strong typing
-------------------------------------------------

[](#example-functional-programming-with-strong-typing)

### Example PHP CLASS

[](#example-php-class)

```
class Dump
{
    public function __construct(ArrayObject $array)
    {
        // first variable
        try {
                if(empty($array->first)){
                    throw new Exception('Undefined property: first');
                }
                var_dump($array->first);

        } catch( Exception $e ) {
           echo 'Problem with ' . $e->getMessage() . "\n";
        }

        // second variable
        try {
            if(empty($array->second))
            {
                throw new Exception('Undefined property: second');
            }
            var_dump($array->second);

        } catch( Exception $e ) {
           echo 'Problem with ' . $e->getMessage() . "\n";
        }
    }
}

```

### 1. Example without parameters

[](#1-example-without-parameters)

#### Code

[](#code)

```
$a = new ArrayObject();
new Dump( $a );

```

#### Result

[](#result)

```
Problem with Undefined property: first
Problem with Undefined property: second

```

### 2. Example with first parameter

[](#2-example-with-first-parameter)

#### Code

[](#code-1)

```
$a = new ArrayObject();
$a->first = 1;
new Dump( $a );

```

#### Result

[](#result-1)

```
int(1)
Problem with Undefined property: second

```

### 3. Example with both parameters

[](#3-example-with-both-parameters)

#### Code

[](#code-2)

```
$a = new ArrayObject();
$a->first = 1;
$a->second = 2;
new Dump( $a );

```

#### Result

[](#result-2)

```
int(1)
int(2)

```

[![alt tag](https://camo.githubusercontent.com/6e861e920df59c4f74bbcaad4cc078a5983764735c0e3fb602c1e3dc4632502a/68747470733a2f2f7068756e632e6f72672f6c6f676f5f7068756e632e706e67)](https://camo.githubusercontent.com/6e861e920df59c4f74bbcaad4cc078a5983764735c0e3fb602c1e3dc4632502a/68747470733a2f2f7068756e632e6f72672f6c6f676f5f7068756e632e706e67)

[![logo Phunc](doc/logo_phunc.png)](doc/logo_phunc.png)

[packagist phunc](https://packagist.org/packages/tom-sapletta-com/phunc)

Install in PHPstorm based on composer project
---------------------------------------------

[](#install-in-phpstorm-based-on-composer-project)

[![phpstorm](install/phpstorm.png)](install/phpstorm.png)

Easy way to install Phunc with APICRA
-------------------------------------

[](#easy-way-to-install-phunc-with-apicra)

### first install apicra:

[](#first-install-apicra)

### install Phunc over apicra

[](#install-phunc-over-apicra)

```
dot phunc install

```

Install Phunc
-------------

[](#install-phunc)

Add the phunc library to your applications composer.json file:

```
composer require tom-sapletta-com/phunc

```

```
{
    "require": {
        "tom-sapletta-com/phunc": "*"
    }
}

```

### Install Composer

[](#install-composer)

Now tell composer to download the library by running the following command:

#### Linux

[](#linux)

```
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

```

#### Windows

[](#windows)

```
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
```

Composer will install the bundle into your project's `vendor/tom-sapletta-com/phunc` directory.

### How to start?

[](#how-to-start)

Add the config classes in new folder `config/`

```
InfoPath.php
ErrorPath.php

```

Add the temporary folder `tmp/`

#### Creating example class ErrorPath

[](#creating-example-class-errorpath)

```
namespace Config;

class ErrorPath
{
    function __toString()
    {
        return '../tmp/error.log.txt';
    }
}

```

#### using example class ErrorPath

[](#using-example-class-errorpath)

```
(string) new ErrorPath();

```

Todo List
---------

[](#todo-list)

see Todo List [here](TODO.md)

Contributors
------------

[](#contributors)

Thanks goes to these wonderful people

[![](https://avatars0.githubusercontent.com/u/5669657?s=460&v=4)
**Tom Sapletta**,
 Project Leader](https://tom.sapletta.com)

This project follows the \[all-contributors\]\[all-contributors\] specification. Contributions of any kind are welcome!

LICENSE
-------

[](#license)

[APACHE2](LICENSE.txt)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5669657?v=4)[Tom Sapletta](/maintainers/tom-sapletta-com)[@tom-sapletta-com](https://github.com/tom-sapletta-com)

---

Top Contributors

[![tom-sapletta-com](https://avatars.githubusercontent.com/u/5669657?v=4)](https://github.com/tom-sapletta-com "tom-sapletta-com (61 commits)")

### Embed Badge

![Health badge](/badges/tom-sapletta-com-phunc/health.svg)

```
[![Health](https://phpackages.com/badges/tom-sapletta-com-phunc/health.svg)](https://phpackages.com/packages/tom-sapletta-com-phunc)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
