phpstats / juphyter
A Jupyter and Quarto kernel for PHP, built for statistical work with the phpstats packages
Requires
- php: >=8.3 <8.6
- ext-mbstring: *
- ext-tokenizer: *
- nikic/php-parser: ^5.0
Requires (Dev)
- pestphp/pest: ^4.0
- squizlabs/php_codesniffer: ^3.13
Suggests
- ext-pcntl: Interrupting a running cell with the stop button
- phpstats/phibble: Data frames shown as notebook tables
- phpstats/phiz: Plots shown as notebook charts
- phpstats/phplyr: dplyr-style pipelines over phibble data frames
Provides
None
Conflicts
None
Replaces
None
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
Requirements
- PHP 8.3, 8.4, or 8.5, with the
mbstringandtokenizerextensions. - Composer.
- Python 3 with the
venvmodule. - macOS or Linux.
The pcntl extension is optional and makes the stop button interrupt a
running cell. Quarto is optional and renders .qmd documents.
Install
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.
Use
In JupyterLab, run jupyter lab and choose the PHP kernel. In Quarto, name the
kernel in the front matter:
--- title: "PHP in Quarto" jupyter: php --- ```{php} echo "sum: ", array_sum(range(1, 10)), "\n"; PHP_VERSION; ```
Then run quarto render hello.qmd.
Development
Contributing covers the tests, the documentation build, and the PHAR.
License
MIT