AI & ML with PHP
44 subscribers
10 photos
39 links
This channel is intended for developers, who interesting in using AI and ML with PHP.
Download Telegram
PHP is not Python, but that doesn't mean it can't be used for machine learning and scientific computing!

There are many legacy PHP libraries that were started 7-10 years ago, were abandoned most likely due to Python and are no longer supported, so I have listed only the most current and actively developed ones (thanks to the loyal PHP community).

Below you may find some of the most powerful libraries available for PHP.

Machine Learning Libraries

๐Ÿ”น Rubix ML โ€“ One of the most powerful ML libraries for PHP.
- Supports more than 40+ supervised and unsupervised algorithms (neural networks, decision trees, clustering).
- Includes data transformation, pipelines, and model evaluation tools. Official website: https://rubixml.com

Mathematical Libraries (for Scientific Computing)

๐Ÿ”น NumPower โ€“ A PHP alternative to NumPy!
- High-performance numerical computing with GPU acceleration.
- Supports multi-dimensional arrays and linear algebra operations.
Official website: https://numpower.org

๐Ÿ”น MathPHP โ€“ A modern mathematics library for PHP.
- Pure PHP with no external dependencies.
- Offers a wide range of mathematical functions.
Official website: https://github.com/markrogoyski/math-php

๐Ÿ”น RubixML/Tensor โ€“ A high-performance tensor and matrix operations library for PHP.
- Optimized for speed using PHPโ€™s native extensions.
- Provides essential linear algebra tools for scientific computing and ML.
Github: https://github.com/RubixML/Tensor

If you are interested in using RubixML in your projects, you can find many video tutorials on youtube. Here is just one example: https://www.youtube.com/watch?v=zJc_Vju72dg
๐Ÿ‘8
If you want to build a career in AI, ML or Big Data

The world of AI, ML and Big Data is growing every day, and if you want to dive into Data & AI, it's important to choose the right path. It's not so simple to decide: who to become? Let's check which options are available today for your choice:

1. Data Scientist โ€“ the AI magician ๐Ÿง™โ€โ™‚๏ธ who builds machine learning models, analyzes data, and makes predictions. Key skills: Python, statistics, ML, SQL, C.
2. Data Analyst โ€“ the data detective ๐Ÿ” who digs deep into numbers, creates reports, and finds hidden patterns. Tools of choice: PHP, SQL, Excel, BI systems (Tableau, Power BI), etc.
3. Data Engineer โ€“ the data architect ๐Ÿ—๏ธ who designs and maintains data pipelines and storage. Must-know: Python, SQL, Spark, ETL, databases.
4. ML Engineer โ€“ the model optimizer ๐Ÿš€ who takes machine learning from theory to production. Required skills: PHP, Python, TensorFlow/PyTorch, DevOps, MLOps.
5. AI Enthusiast โ€“ the explorer ๐ŸŒ who experiments with AI, joins Kaggle competitions, and builds cool projects just for fun. Required skills: PHP, Python, JS, databases. etc.

Which role suits you best?
โœ3๐Ÿ‘3
What to read?

I'm planning to post here information about books, articles or other interesting materials related to AI or ML. This is the first one. So.. Get it:

Andriy Burkov, The Hundred-Page Language Models Book
https://themlbook.com/

This book provides a practical guide to get started and execute on machine learning within a few days without necessarily knowing much about machine learning.

โœ… Pros
1. Straight to the Point โ€“ The book explains machine learning ideas quickly and clearly without extra details. This makes it great for busy people.
2. Easy for Beginners โ€“ It gives a simple introduction to machine learning, so newcomers wonโ€™t feel lost.
3. Includes Some Math โ€“ It covers important math concepts like probability and algebra, but it doesnโ€™t go too deep.
4. Helpful for Interviews โ€“ If you're preparing for a machine learning job interview, this book is a great refresher.
5. Covers Old and New ML Methods โ€“ It talks about basic models like decision trees and modern AI like deep learning.

โŒ Cons
1. Too Short for Deep Learning โ€“ The book moves very fast, so you might need another book for more details.
2. Not Many Code Examples โ€“ It explains ML well but doesnโ€™t show much actual coding. If you want hands-on practice, you'll need another resource.
3. Some Prior Knowledge Helps โ€“ While itโ€™s good for beginners, a basic understanding of math and ML will make it easier to follow.

๐ŸŽ“ The Verdict
This book is like a pocket-sized AI mentor โ€” super useful, incredibly insightful, and refreshingly brief. But if you're looking for deep, hands-on coding exercises or advanced ML theory, you'll need something else.
Not sure if you're ready to buy it? Read this first: https://themlbook.com/wiki/doku.php
๐Ÿ‘5๐Ÿ‘1
AI-Powered PHP Agents in Action!

If youโ€™re a PHP developer looking to add AI to your projects, the LLM Agents PHP SDK makes it super easy. You can build smart agents that automate tasks, analyze data, and interact with external toolsโ€”all with minimal effort.

Here are two cool real examples, see live demo with code example:

๐Ÿ”น Site Status Checker โ€“ Monitors website uptime and performance, instantly notifying you of any issues.
https://aiwithphp.org/examples/ai-agents/llm-agents/site-status-checker-agent-run

๐Ÿ”น Sales Analysis Agent โ€“ Analyzes sales data, spots trends, and helps businesses make better decisions.
https://aiwithphp.org/examples/ai-agents/llm-agents/sales-analysis-agent-run

P.S. The result is cached, so if you want to install this code examples on your server, you should use your own OpenAI key.
๐Ÿ‘4
Problem Solving in AI

Search algorithms in AI are designed to assist in identifying the best solution to a problem. A search problem typically consists of a search space, an initial state, and a goal state.

Generally we have following types of searches:
- Uninformed Search: Requires no additional information beyond the problem definition.
- Informed Search: Utilizes heuristics or additional knowledge to improve efficiency.
- Global Search: Explores the entire problem space systematically or with guidance (e.g., BFS, A*). These algorithms are more exhaustive but computationally expensive.
- Local Search: Focuses on improving solutions in a specific area without exploring the entire space (e.g., Hill Climbing, Simulated Annealing). These algorithms are more efficient for large spaces but may miss the optimal solution.

Live Demos:
https://aiwithphp.org/examples/problem-solving/index
๐Ÿ‘5
News: OpenAI introduced a new level of image generation.

OpenAI has launched a better image generation tool in ChatGPT, using the new GPT-4o model. One big change is that this feature is now available not only for paid users (Plus, Pro, Team), but also for free users, who can generate up to 3 images per day.

The new generator is much better than the previous version, which used DALL-E 3. It understands more complex requests, shows text on images correctly, and creates images in a clear order โ€“ from left to right and top to bottom. At the same time, users can still access the old DALL-E 3 generator.

See the result for simple prompt "generate image where PHP programmer explains AI & ML for PHP
๐Ÿ‘6โค2
Will there be a 3rd AI Winter? Is this possible at all?

Doesn't it seem too early for such questions?

I think there could be a 3rd AI winter after this big boom with large language models (LLMs), like ChatGPT, but it might not be as serious as the ones in the past. The LLM boom (GPT-4, Claude, Gemini, etc.) has raised expectations sky-high, and that's usually the perfect setup for disillusionment. Although the context today is very different from the '70s and '80s.

In the past, AI winters happened when people expected too much from AI and got disappointed. I feel like the same thing might happen now. Many people believe LLMs can do everything โ€” replace humans, solve all problems โ€” but that's not really true. If companies will spend a lot of money on AI and don't see good results, they might stop investing.

Also, if AI makes mistakes, causes bias, or is used in the wrong way, governments might bring in strong rules. That could slow down AI development. Another problem is that training these big models takes a lot of money and energy, which isn't sustainable forever.

On the other hand, I don't think we'll have a complete AI winter. AI is already in so many tools people use every day โ€” like search engines, writing assistants, and coding tools. And it's not just about LLMs; there's also progress in robotics, computer vision, and smaller, open-source models. That means innovation won't stop completely.

So in my opinion, we might see a slowdown โ€” something like an AI autumn, not a full winter. Some companies might shut down or change direction, but AI will still move forward, just in a more realistic and useful way.

But when exactly? May be next year, may be later. Sorry, but I don't really know... ๐Ÿ˜œ
๐Ÿ‘1
๐Ÿ‘3๐Ÿค”2
OMG! Sam Altman was right and I'm wrong...

Today, the first time I editied my previously written code with Chat GPT directly without copy-paste by voice command.
Ream more: https://help.openai.com/en/articles/10119604-work-with-apps-on-macos

When working with IDEs, you can ask ChatGPT to edit open files directly โ€” no copy-pasting required. When you ask for an edit, ChatGPT will generate a diff that you can review and apply, and thereโ€™s also an option to automatically apply edits. Diffs are easy to revert in the ChatGPT UI, or by using CMD+Z in your editor.
๐Ÿ‘6
Machine Learning Capabilities in PHP
Yes, I do and I use it in my projects.

When people talk about machine learning, PHP rarely comes up. Python and R dominate the conversation โ€” and for good reason. But hereโ€™s an interesting fact: PHP still powers nearly 75% of the web (https://w3techs.com/technologies/details/pl-php), and in recent years, itโ€™s been quietly gaining machine learning capabilities.

Why should you, PHP developer, care?
Because now you can build smarter web apps โ€” like recommendation engines, predictive analytics, or spam filters โ€” without leaving PHP.

Here are some PHP libraries bringing ML to the table:

๐Ÿ”น Rubix ML (https://rubixml.com) โ€“ A modern, production-ready library with support for neural networks, decision trees, clustering, and more. It also includes tools for data prep and evaluation.

๐Ÿ”น PHP-ML (https://php-ml.readthedocs.io) โ€“ One of the first full-featured ML libraries in PHP. Offers popular algorithms like k-NN and SVM. Ideal for adding basic ML features without deep expertise.

But it doesnโ€™t stop there. PHP is also getting stronger in scientific computing:

โ–ช๏ธ NumPower (https://numpower.org) โ€“ A high-performance extension with GPU acceleration via CUDA. Comparable to NumPy in Python.

โ–ช๏ธ MathPHP (https://github.com/markrogoyski/math-php) โ€“ A robust math library written entirely in PHP. No external dependencies.

โ–ช๏ธ RubixML/Tensor (https://github.com/RubixML/Tensor) โ€“ Provides fast tensor and matrix operations, optimized for PHP-based data science.

Interesting fact: RubixML and Tensor are written in native PHP, proving that you donโ€™t need Python to get decent ML performance โ€” especially for web-scale problems.

Want to connect with more powerful ML tools?
You can combine PHP with TensorFlow.js or Brain.js. These run in the browser (JavaScript) and send results back to your PHP backend โ€” great for hybrid web apps.

Of course, PHP may not be the first choice for machine learning, but it's growing quietly in that space. For us, PHP developers, that means we can add intelligence to our apps using the tools we already know.
๐Ÿ‘4
Last Trend for PHP + AI. May be this is new upward trend line? Who knows...
๐Ÿค”3๐Ÿ‘1
The MCP protocol (Message Control Protocol) plays a crucial role in enhancing communication with Large Language Models (LLM). MCP ensures reliable message exchange by managing message formatting, transmission, and error handling. This becomes particularly beneficial when interacting with LLM models.

See this video about MCP. Just few minutes of very high quality content, explaining what is MCP.
https://www.youtube.com/watch?v=qPVtVulhFC4
๐Ÿ‘6
Windsurf Wave 7: Cascade Comes to JetBrains!

Great news! Windsurf (formerly Codeium) has launched Wave 7, bringing the full Cascade AI experience to JetBrains IDEs like IntelliJ, PhpStorm, WebStorm, and PyCharm.
https://windsurf.com/blog/windsurf-wave-7

Now you can:
โœ… Use Write, Chat, and Legacy modes
โœ… Access all Cascade tools inside the editor
โœ… Work with AI directly in your terminal
โœ… Enjoy a smooth agent-based coding flow

This is a big step for AI coding tools in JetBrains. And more features are coming soon!

๐ŸŒŠ Itโ€™s all Windsurf now โ€” one name, one platform, full AI power for your PHP+ projects!
๐Ÿ”ฅ6๐Ÿ‘2โค1
Scalars, Vectors, Matrices & Tensors โ€” The Language of ML

If you're diving into Machine Learning, don't skip the basics! ๐Ÿ’ก
Understanding scalars, vectors, matrices, and tensors is crucial โ€” theyโ€™re the building blocks of how data is represented and processed.

๐Ÿ”น Scalar โ†’ A single number (like temperature: 36.6)
๐Ÿ”น Vector โ†’ A list of numbers (like pixel values in a grayscale image row)
๐Ÿ”น Matrix โ†’ 2D grid of numbers (like an image with width & height)
๐Ÿ”น Tensor โ†’ Multi-dimensional array (think colored videos with time, RGB, height & width!)

From feeding input to a neural network to backpropagation โ€” it's all tensors under the hood.

Master these, and you're speaking the native tongue of ML models.
You may see the code example for each of these elements:
https://aiwithphp.org/examples/mathematics/index
Read curefully:
https://apphp.gitbook.io/artificial-intelligence-with-php/machine-learning/mathematics-for-ml/linear-algebra
๐Ÿ‘6
Using spaCy with PHP: Natural Language Processing in Your PHP Apps!

Did you know you can harness the power of spaCy (https://spacy.io) - one of Pythonโ€™s most advanced NLP libraries - even in a PHP project? Hereโ€™s how! ๐Ÿ‘‡

This library - spaCy - offers fast and accurate tokenization, named entity recognition, part-of-speech tagging, and more. While PHP isnโ€™t natively built for NLP, you can bridge the gap with Python.

But, your may easily integrate spaCy with PHP
1. Create a Python script
Use spaCy to process text and output results as JSON. Example:

# nlp.py
import spacy
import sys
import json

nlp = spacy.load("en_core_web_sm")
text = sys.argv[1]
doc = nlp(text)

result = {
"tokens": [token.text for token in doc],
"entities": [(ent.text, ent.label_) for ent in doc.ents]
}
print(json.dumps(result))


2. Call the script from PHP

$text = "Elon Musk founded SpaceX in 2002.";
$escapedText = escapeshellarg($text);
$command = "python3 nlp.py $escapedText";
$output = shell_exec($command);
$result = json_decode($output, true);

print_r($result);
?>


Thatโ€™s it! You now have spaCy-powered NLP inside your PHP app. It's perfect choice for chatbots, content tagging, semantic search, or anything involving language understanding.
๐Ÿ‘4๐Ÿ‘1