PHPackages                             deralex/phprainfuck - 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. deralex/phprainfuck

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

deralex/phprainfuck
===================

Brainfuck interpreter and virtual machine

2019.x-dev(6y ago)1231MITPHPCI failing

Since Oct 8Pushed 6y agoCompare

[ Source](https://github.com/deralex/phprainfuck)[ Packagist](https://packagist.org/packages/deralex/phprainfuck)[ RSS](/packages/deralex-phprainfuck/feed)WikiDiscussions master Synced today

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

phprainfuck - Brainfuck interpreter and virtual machine in PHP
==============================================================

[](#phprainfuck---brainfuck-interpreter-and-virtual-machine-in-php)

What the heck is this?
----------------------

[](#what-the-heck-is-this)

It's a Brainfuck interpreter and (somewhat) virtual machine which makes it possible to both evaluate brainfuck code as "pure" brainfuck code and to evaluate brainfuck code as PHP code.

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

[](#installation)

Just add it to your composer.json:

```
"require": {
    ...
    "AlexClooze/phprainfuck": "dev-master"
}

```

and run `composer update`.

Usage
-----

[](#usage)

There are two ways of using phprainfuck.

It all starts with creating a new instance of phprainfuck:

```
use AlexClooze\Phprainfuck\Phprainfuck;

$phprain = new Phprainfuck();

```

After this you've got two options.

### Interpreting brainfuck code "as is"

[](#interpreting-brainfuck-code-as-is)

Here's an example on using the `evaluate` method to just interprete pure brainfuck code:

```
$code = evaluate($code);

```

This will print "Hello World!".

### Evaluating brainfuck code as PHP code

[](#evaluating-brainfuck-code-as-php-code)

Here's an example on creating a new virtual machine and executing brainfuck code as PHP code in it.

*Hint*: All code executed via the virtual machine is executed in a seperate new PHP process.

```
$code = ---- ----< ]>--- ----- ----- --.+ +++++ ++ +++++
.+ +++++++ ++++. +++.- ----- .---- ----. ---
----- -- -.+.+ +++++ +. ++++< ]>++. <
EOT;

$vm = $phprain->createVirtualMachine(255);
$vm->run($code);

```

The argument given by `createVirtualMachine` is the actual heap size. The above code will evaluate to `var_dump("Hello World!");` and will print `string(12) "Hello World!"`.

Running tests
-------------

[](#running-tests)

phprainfuck is developed with the help of phpspec. Run `phpspec run` to run the tests.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

2456d ago

### Community

Maintainers

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

### Embed Badge

![Health badge](/badges/deralex-phprainfuck/health.svg)

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

###  Alternatives

[ec-europa/toolkit

Toolkit packaged for Drupal projects based on Robo.

39250.0k28](/packages/ec-europa-toolkit)

PHPackages © 2026

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