PHPackages                             phunkie/console - 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. [CLI &amp; Console](/categories/cli)
4. /
5. phunkie/console

ActiveLibrary[CLI &amp; Console](/categories/cli)

phunkie/console
===============

A console for Phunkie development

1.1.0(5mo ago)07MITPHPPHP ^8.2 || ^8.3 || ^8.4CI passing

Since Oct 19Pushed 5mo agoCompare

[ Source](https://github.com/phunkie/console)[ Packagist](https://packagist.org/packages/phunkie/console)[ RSS](/packages/phunkie-console/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (5)Used By (0)

Phunkie Console
===============

[](#phunkie-console)

[![CI](https://github.com/phunkie/console/actions/workflows/ci.yml/badge.svg)](https://github.com/phunkie/console/actions)[![PHP Version](https://camo.githubusercontent.com/620eff0f0e0df8ea6dee6f11b044dcf7b21be416b59632c65de55a10ebbded98/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068756e6b69652f636f6e736f6c653f636f6c6f723d383839324246)](https://packagist.org/packages/phunkie/console)[![Latest Stable Version](https://camo.githubusercontent.com/decf51eb54208199e24edd919e8d2601d716d76acc18120686e2bced22ced6a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068756e6b69652f636f6e736f6c65)](https://packagist.org/packages/phunkie/console)[![Total Downloads](https://camo.githubusercontent.com/a0cd62c5e8548b18eaf50cfbfd0d153352db571d6844634a66fdbe9aafb0cc5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068756e6b69652f636f6e736f6c65)](https://packagist.org/packages/phunkie/console)[![License](https://camo.githubusercontent.com/ae8baae0c2a337e90416cf524a4692954f8f391d6cd5ea535a5db4584cc314ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068756e6b69652f636f6e736f6c65)](https://github.com/phunkie/console/blob/main/LICENSE)

A powerful, interactive REPL (Read-Eval-Print Loop) console for [Phunkie](https://github.com/phunkie/phunkie) - bringing functional programming to PHP.

Features
--------

[](#features)

- **Interactive REPL**: Evaluate PHP expressions and see results immediately
- **Functional Programming**: Full access to Phunkie's functional programming constructs
- **Type Inspection**: Query types and kinds of expressions with `:type` and `:kind` commands
- **Import System**: Import functions from Phunkie standard library on-the-fly
- **Syntax Highlighting**: Color-coded output for better readability
- **Multi-line Support**: Write complex expressions across multiple lines
- **Rich Output**: Formatted display of complex data structures

Requirements
------------

[](#requirements)

- PHP 8.2, 8.3, or 8.4
- Composer

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

[](#installation)

```
composer require phunkie/console
```

Or install globally:

```
composer global require phunkie/console
```

Usage
-----

[](#usage)

Start the REPL:

```
php vendor/bin/phunkie
```

Or if installed globally:

```
$ phunkie
Welcome to phunkie console.

Type in expressions to have them evaluated.

phunkie >
```

### Basic Examples

[](#basic-examples)

```
phunkie > 1 + 2
$var0: Int = 3

phunkie > ImmList(1, 2, 3, 4, 5)->map(fn($x) => $x * 2)
$var1: ImmList = List(2, 4, 6, 8, 10)

phunkie > Some(42)->map(fn($x) => $x * 2)
$var2: Option = Some(84)
```

### REPL Commands

[](#repl-commands)

- `:quit` or `:exit` - Exit the REPL
- `:type ` - Show the type of an expression
- `:kind ` - Show the kind of a type
- `:import ` - Import a function from the Phunkie standard library
- `:load ` - Load a PHP file silently (all definitions become available in the session)
- `:help` - Show help information

### Working with Options

[](#working-with-options)

```
phunkie > Some(42)->getOrElse(0)
$var0: Int = 42

phunkie > None()->getOrElse(0)
$var1: Int = 0

phunkie > Some(10)->flatMap(fn($x) => Some($x * 2))
$var2: Option = Some(20)
```

### Working with Immutable Collections

[](#working-with-immutable-collections)

```
phunkie > $list = ImmList(1, 2, 3, 4, 5)
$var0: ImmList = List(1, 2, 3, 4, 5)

phunkie > $list->filter(fn($x) => $x > 2)
$var1: ImmList = List(3, 4, 5)

phunkie > $list->reduce(fn($acc, $x) => $acc + $x, 0)
$var2: Int = 15
```

### Multi-line Expressions

[](#multi-line-expressions)

The REPL automatically detects incomplete expressions and prompts for continuation:

```
phunkie > function double($x) {
phunkie {   return $x * 2;
phunkie { }
imported function double()

phunkie > double(21)
$var0: Int = 42
```

### Examples with REPL Commands

[](#examples-with-repl-commands)

```
phunkie > :type ImmList(1, 2, 3)
ImmList

phunkie > :kind Option
* -> *

phunkie > :import strlen
imported function strlen()

phunkie > strlen("hello")
$var0: Int = 5

phunkie > :load helpers.php
// file helpers.php loaded

phunkie > // Now all functions and classes from helpers.php are available
```

Configuration
-------------

[](#configuration)

### Color Support

[](#color-support)

Enable colors with the `-c` flag:

```
php vendor/bin/phunkie -c
```

Development
-----------

[](#development)

### Running Tests

[](#running-tests)

Run all tests:

```
./vendor/bin/phpunit
./vendor/bin/behat
```

Run version-specific tests:

```
./bin/run-behat-tests.sh
```

### Test Coverage

[](#test-coverage)

The project maintains comprehensive test coverage:

- **Unit Tests**: Testing individual components with PHPUnit
- **Acceptance Tests**: End-to-end REPL functionality with Behat
- **Cross-version Testing**: Automated testing across PHP 8.2, 8.3, and 8.4

### Code Quality

[](#code-quality)

```
# Static analysis
./vendor/bin/phpstan analyze

# Code style
./vendor/bin/php-cs-fixer fix
```

Architecture
------------

[](#architecture)

The console is built with a modular architecture:

- **Parser**: Uses nikic/php-parser for PHP syntax analysis
- **Evaluator**: Safe evaluation of PHP expressions
- **Session**: Stateful session management using the State monad
- **Display**: Formatted output with type information
- **Terminal**: Readline integration for command history

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

Links
-----

[](#links)

- [Phunkie Library](https://github.com/phunkie/phunkie)
- [Documentation](./docs/index.md)
- [Issue Tracker](https://github.com/phunkie/console/issues)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance73

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

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.

###  Release Activity

Cadence

Every ~30 days

Total

3

Last Release

152d ago

Major Versions

v0.1 → 1.0.02025-12-13

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/70713?v=4)[md](/maintainers/md)[@md](https://github.com/md)

---

Top Contributors

[![MarcelloDuarte](https://avatars.githubusercontent.com/u/144535?v=4)](https://github.com/MarcelloDuarte "MarcelloDuarte (33 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phunkie-console/health.svg)

```
[![Health](https://phpackages.com/badges/phunkie-console/health.svg)](https://phpackages.com/packages/phunkie-console)
```

###  Alternatives

[psy/psysh

An interactive shell for modern PHP.

9.8k545.6M719](/packages/psy-psysh)[humbug/php-scoper

Prefixes all PHP namespaces in a file or directory.

7963.0M35](/packages/humbug-php-scoper)[worksome/envy

Automatically keep your .env files in sync.

6871.8M](/packages/worksome-envy)[povils/phpmnd

A tool to detect Magic numbers in codebase

5795.6M193](/packages/povils-phpmnd)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1862.1M27](/packages/dereuromark-cakephp-ide-helper)[tmuras/moosh

Moosh stands for MOOdle SHell. It is a command-line tool that will allow you to perform most common Moodle tasks.

2541.4k](/packages/tmuras-moosh)

PHPackages © 2026

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