Zum Inhalt springen

AI and Machine Learning Directly in PHP: What's Already Possible Today

Artificial intelligence is generally considered the domain of Python—but are there other options? Frank Berger, Head of Engineering at the Stuttgart-based agency Sudhaus7, demonstrated at the TYPO3 Developer Days 2026 how AI and machine learning models can be used directly in PHP. He covered a wide range of topics, from pure PHP frameworks to high-performance extensions and large language models. Using live examples such as sentiment analysis, text-to-speech conversion, and image description, he made it clear that PHP developers don’t necessarily have to switch languages to get started with AI. The presentation dispelled the misconception that PHP is unsuitable for modern AI applications.

For a long time, the conventional wisdom was that anyone working with AI couldn’t do without Python. In his presentation, Frank Berger showed that this view is changing. Even with the PHP framework RubixML, neural networks can be fully trained and deployed in PHP.

For computationally intensive tasks, Berger introduced PHP extensions such as Tensor, NumPower, and NDArray. These extensions utilize the proven BLAS and LAPACK math libraries in the background and can even incorporate the graphics card. In a direct comparison, an operation calculated with NumPower was about 16 times faster than the pure PHP version.

A key topic was the open model standard ONNX (Open Neural Network Exchange), which is maintained by the Linux Foundation. It allows models trained in Python or other frameworks to be executed in PHP as well, for example via PHP’s own FFI interface. Using sentiment analysis, he demonstrated live how a sentence is automatically classified as positive, negative, or neutral.

More complex applications were also demonstrated: a text-to-speech implementation in which PHP generates spoken sentences, as well as automatic image description. The “TransformersPHP” project by developer Kyrian also provides a PHP counterpart to the well-known Python library Transformers, which significantly simplifies working with Hugging Face models.

To wrap up, Frank showed how the “PHP-Llama” extension—developed by PHP inventor Rasmus Lerdorf—can be used to control even large language models like Llama directly from within PHP, including chat and streaming functions.

His conclusion: Machine learning and AI are no longer a distant prospect in PHP, even if the ecosystem is still in its infancy in some areas and requires further development. All examples from the presentation are available as code on GitHub.

Frank Berger from Sudhaus 7 during his presentation at the TYPO3 Developer Days 2026

Frank Berger

This page contains automatically translated content.