Search by

phpstats / juphyter

erikwestlund

A Jupyter and Quarto kernel for PHP, built for statistical work with the PHPstats packages

Package info

github.com/phpstats/juphyter

pkg:composer/phpstats/juphyter

Statistics

Installs: 26

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.1 2026-10-31 17:02 UTC

This package is auto-updated.

Last update: 2026-11-02 12:15:19 UTC


README

juphyter is a Jupyter kernel for PHP. It runs PHP cells in JupyterLab notebooks and in Quarto documents, keeps one PHP session across cells, and shows phibble data frames as tables and phiz plots as charts.

Documentation: https://juphyter.phpstats.org

Features

  • One PHP session across cells, including use imports and declared functions and classes.
  • HTML tables for phibble data frames and charts for phiz plots, plus toHtml() and toMimeBundle() hooks for any class.
  • Juphyter\display() to show values part way through a cell.
  • Tracebacks that name the cell and the line.
  • Completion of variables, functions, classes, and members.
  • Interrupting a running cell, when PHP has the pcntl extension.
  • The nearest vendor/autoload.php above a notebook is loaded, so a notebook inside a Composer project can use its classes and packages.

Requirements

  • PHP 8.3, 8.4, or 8.5, with the mbstring and tokenizer extensions.
  • Composer.
  • Python 3 with the venv module.
  • macOS or Linux.

The pcntl extension is optional and makes the stop button interrupt a running cell. Quarto is optional and renders .qmd documents.

Installation

composer global require phpstats/juphyter
export PATH="$(composer global config bin-dir --absolute):$PATH"
juphyter install --create-venv ~/.venvs/juphyter
export PATH="$HOME/.venvs/juphyter/bin:$PATH"
juphyter doctor

juphyter install registers the kernel as php. It uses an existing Python environment that has ipykernel 7, or builds one with JupyterLab at ~/.venvs/juphyter. The export lines last for the current shell. juphyter doctor checks the installation and exits 1 when something is broken. The installation guide covers keeping the PATH entries, the PHPstats packages, and per-project installs.

Usage

In JupyterLab, run jupyter lab and choose the PHP kernel. In Quarto, name the kernel in the front matter:

---
title: "Fuel economy"
jupyter: php
---

```{php}
$mtcars = \Phibble\DataFrame::fromCsv(
    'https://raw.githubusercontent.com/phpstats/datasets/main/csv/mtcars.csv'
);
$mtcars;
```

The cell reads mtcars from the PHPstats datasets repository, so the document sits in a Composer project that requires phpstats/phibble. Save it as mtcars.qmd and run quarto render mtcars.qmd.

Contributing

Contributing covers the tests, the documentation build, and the PHAR.

License

juphyter is released under the MIT license. See LICENSE. THIRD_PARTY_NOTICES.md lists the licenses of the third-party files in the rendered documentation.