juphyter

Guide

JupyterLab

Starting a notebook

Start JupyterLab from the Python environment that has it:

~/.venvs/juphyter/bin/jupyter lab

The launcher lists each kernel juphyter registered under its display name, such as “PHP 8.5” for the default php kernel and “PHP (phpstats)” for the kernel from Installation. A notebook that is already open changes kernel through Kernel > Change Kernel.

JupyterLab finds kernels in the per-user Jupyter data directory and in JUPYTER_DATA_DIR when it is set. jupyter kernelspec list shows the kernels a JupyterLab started from the same environment will find.

Running cells

A cell’s result appears under it as Out[n]. State carries from one cell to the next. The stop button interrupts a running cell when PHP has the pcntl extension, and Kernel > Restart Kernel starts a new PHP session with nothing defined.

Tab completion covers three cases:

  • Variables in the session, after a $.
  • Declared functions and classes, for a bare prefix.
  • Public methods, properties, and constants, after -> or ::.

An unfinished block or string keeps the cell open for another line instead of running it.

Project classes

Jupyter starts the kernel in the notebook’s directory. The kernel looks upward from there for vendor/autoload.php, so a notebook saved inside a Composer project can use that project’s classes and packages.

A notebook kept outside the project it works on names the autoloader in a juphyter.json beside it:

{
  "autoload": "../app/vendor/autoload.php"
}

Which classes a notebook sees lists every way to set it.

Tables

A phibble data frame appears as an HTML table with its dimensions and column types. The table’s styles use JupyterLab’s theme variables, so it follows the light and dark themes.

DataFrame::fromRows([
    ['front end' => 'JupyterLab', 'plot from' => 'the Vega-Lite spec', 'table from' => 'text/html'],
    ['front end' => 'Quarto HTML', 'plot from' => 'the HTML embed', 'table from' => 'text/html'],
    ['front end' => 'Quarto PDF', 'plot from' => 'the static SVG', 'table from' => 'the parsed table'],
]);
A tibble: 3 × 3
front end <chr> plot from <chr> table from <chr>
1 JupyterLab the Vega-Lite spec text/html
2 Quarto HTML the HTML embed text/html
3 Quarto PDF the static SVG the parsed table

Plots

JupyterLab draws a phiz plot from its Vega-Lite specification and needs no extension for it. phiz writes Vega-Lite 6 specifications, and juphyter publishes them under application/vnd.vegalite.v5+json, the newest Vega-Lite type JupyterLab’s built-in renderer accepts. On 2026-10-19, with phiz 0.3, JupyterLab’s bundled Vega-Lite 5.6.1 compiled all sixteen phiz specifications tested.

juphyter also publishes a static SVG and an HTML version of each plot. JupyterLab uses neither. It does not run scripts in HTML output, and the HTML version is a container with a script that draws the chart, so it would show as an empty box. The SVG serves Quarto’s PDF and Word output, front ends without JavaScript, and any Vega-Lite 6 construct that the version 5 renderer rejects.

Converting a notebook

quarto convert turns a .ipynb into a .qmd and back, and jupyter nbconvert exports a notebook to HTML or PDF. Both work on a PHP notebook, because they read the notebook file format and not the language.

From phpstats/juphyter@57dda5a.