Sunday, June 22, 2025

Overview of NLP Libraries in PHP

 

1. OpenAI Integrations for PHP

OpenAI PHP Client on the editor

One of the most powerful Natural Language Processing (NLP) libraries available for PHP developers is the OpenAI PHP Client. This library provides an easy-to-use interface for integrating OpenAI’s language models, including GPT-based models, into PHP applications. The OpenAI PHP Client is designed to simplify communication with OpenAI’s API.

OpenAI PHP Extension

Official website: https://openai-php.com

The OpenAI PHP is an extension that allows PHP developers to integrate the powerful capabilities of OpenAI into their applications. Activating the extension on the web server will allow users to quickly access the services offered by OpenAI without additional libraries in PHP.

2. General NLP/AI Frameworks for PHP

EasyAI-PHP

EasyAI-PHP is an open-source initiative designed to significantly simplify the entry into artificial intelligence for PHP-developers (so basically Lang-Chain for PHP). This project integrates advanced AI models and utilities, allowing developers to incorporate complex AI functionalities with minimal coding.

LLPhant

LLPhant - A comprehensive PHP Generative AI Framework

TransformersPHP

State-of-the-art Machine Learning for PHP. Run Transformers natively in your PHP projects

3. NLP Agent & Workflow Frameworks

LLM Agents PHP SDK (PHP LLM-based AI Agents Library)


The LLM Agents PHP SDK is a robust PHP library designed to facilitate the creation and management of Language Model (LLM)-based agents. It offers a comprehensive framework that enables developers to build autonomous agents capable of performing complex tasks, making informed decisions, and interacting seamlessly with various tools and APIs.
  • Agent Creation: Define and configure LLM-based agents with customizable behaviors.
  • Tool Integration: Connect agents with various tools and APIs for extended functionality.
  • Memory Management: Enable agents to retain and recall information for better context.
  • Prompt Handling: Manage prompts efficiently to guide agent responses.
  • Extensible Architecture: Easily add new agent types, tools, and capabilities.
  • Multi-Agent Support: Allow multiple agents to collaborate on complex tasks.

4. NLP Utility Libraries

DeepL-php (PHP client library for the DeepL API)

The DeepL API is a language translation API that allows other computer programs to send texts and documents to DeepL's servers and receive high-quality translations. This opens a whole universe of opportunities for developers: any translation product you can imagine can now be built on top of DeepL's best-in-class translation technology.

Sunday, March 02, 2025

 

New Telegram Channel: AI & ML with PHP

 We’re excited to announce the launch of our new Telegram channel: AI & ML with PHP! If you're interested in Artificial Intelligence (AI), Machine Learning (ML), and how they integrate with PHP, this is the place for you.

What You’ll Find in Our Channel

Our goal is to bring together developers, AI enthusiasts, and PHP programmers to explore the possibilities of AI & ML in PHP. Here’s what you can expect:


  • AI & ML Tutorials for PHP Developers
  • Code Snippets & Hands-On Examples
  • Latest News & Trends in AI & ML
  • Tips for Using AI in PHP Projects
  •  Engaging Discussions & Q&A Sessions

Why Should You Join?

AI and ML are shaping the future of technology, and PHP is still one of the most widely used languages in web development. Combining them opens up new possibilities for automation, data analysis, and intelligent applications. Whether you’re a beginner or an expert, our channel will keep you updated, informed, and inspired.

Join Us Today

Be part of our growing community and take your PHP skills to the next level with AI & ML. Click below to join now:

t.me/aimlphp

Let’s build the future of AI-powered PHP applications together.

Saturday, November 02, 2024

Announcing New Online Book: “Artificial Intelligence with PHP”

I’m thrilled to announce my new project - online book "Artificial Intelligence with PHP"! This book is designed for developers, tech enthusiasts, and anyone interested in diving into artificial intelligence with a specific focus on PHP. AI is a transformative field that touches everything from daily convenience to the world’s most complex problems, and PHP, a language loved for web development, can be an excellent tool to explore it.












In AI with PHP, we’ll cover essential topics in AI, machine learning, deep learning, and neural networks — all with practical PHP examples. From the foundational principles of AI to the intricacies of deep learning algorithms, this book will guide you step-by-step. Whether you’re curious about how AI models make decisions or eager to build your own neural network, there’s something here for you. 

Here’s a sneak peek at some of the core topics: 
  • Artificial Intelligence Fundamentals – A primer on AI concepts, terms, and history, tailored to PHP developers. 
  • Machine Learning Basics – Understand core algorithms and explore how data shapes the models we create. 
  • Deep Learning and Neural Networks – Delve into advanced AI, from creating neural networks to implementing deep learning architectures. 
  • PHP Code Examples – Hands-on code samples to apply AI concepts in real-world scenarios using PHP libraries like Rubix ML, PHP-ML and others.

One of the most exciting aspects of AI with PHP is that it’s both open-source and open for collaboration! The book is still a work in progress, and I invite anyone with a passion for AI, PHP, or both to contribute. Whether you’re an experienced developer, a newcomer to AI, or just enthusiastic about the field, your input can help make this resource richer and more valuable for everyone. As a contributor, you’ll have the chance to shape content, suggest new sections, and help others learn alongside you. 

AI has never been more accessible, and with PHP as our toolkit, we can tackle exciting AI projects together. I can’t wait to share this journey with you. Stay tuned for more updates, sample chapters, and release dates. Let’s explore the future of AI — together, with PHP, in a truly collaborative, open-source way! 

The official website of the book (v0.1): 
https://apphp.gitbook.io/artificial-intelligence-with-php

The GitHub repository with practical examples: 
https://github.com/apphp/ai-with-php-examples

Saturday, March 06, 2021

New version 1.4.1 of ApPHP MVC Framework is released

 


ApPHP MVC Framework is designed to provide modern and rapid development of websites, web applications and web services. It implements the the Model-View-Controller (MVC) design pattern and principles, including separation of display, logic, and data layers. It provides an architecture, components and tools for developers to build a complex web applications faster and safer. There are many changes and improvements in new version. You can review all recent changes here.

Friday, November 27, 2020

Laravel - Specify Custom Folders for Migration Files

By default in Laravel you have all migration files in on folder, that called database/migrations/

It's cool, but if your project has grown, you may found this folder includes a lot of files and it's not easy to support them. The best solution is to create sub-directories (according to your needs or per version) and create/put your migrations files in specific directory.

This is the standard way how we use migration files:


 

 


 

 

 

 

 

 

 

Let's try to improve this. For example you may decide to separate migration files according to the version of your script, so the structure of your migration directory will look like this:








 

Looks much better, right? Instead of a long list of migration files.

So when you start new version, you need to create a new directory, name it with the next version number and all migrations, related to this version create only in new directory.

Is this enough? Not really.

But default Laravel waiting you place migration files directly in database/migrations/ directory, not in sub-directories. So we just need to inform Laravel from where it has to take migration files. Let's do it.

We have to open AppServiceProvider.php file, and add in the boot() method following code, that will tell to Laravel from where take migration files.

/*
|--------------------------------------------------------
|  Register custom migration paths
|  We specify sub-directory for each version, like:
|      - database/migrations/0.8.1/
|      - etc.
| You may use DIRECTORY_SEPARATOR instead of /
|-------------------------------------------------------- */ $this->loadMigrationsFrom([ database_path().'/migrations/0.8.1', database_path().'/migrations/0.8.2', database_path().'/migrations/0.8.3', ]);

Next time you will add a new directory, just remember to update this list of default directories.


Saturday, November 21, 2020

2020 Black Friday Week Sales Started!

 



Hi, everyone, this 2020 Black Friday Week Sales!

Enjoy with a 50% Offer till 28 Novmber 2020 ONLY!

Coupon Code:
2020-BFRI-9BM0-GNIA






Valid on:
https://apphp.com

uHotelBooking - hotel management, reservation and online booking system for all types of accommodations and hotel operations.
http://hotel-booking-script.com

 uBusinessDirectory - fully-featured web solution for business listings, classifieds directory and yellow pages website.

http://business-directory-script.com

uAutoDealers - fully-featured web solution for car dealerships and auto classified websites
http://auto-dealers-script.com

uDoctorAppontment - clinic management, doctor and therapist online medical appointment scheduling system for the management of health care appointments.
http://doctor-appointment-script.com

uBidAuction -PHP auction script, popular and cost effective solution to launch your Classic and Bid auctions website.
http://www.bid-auction-script.com/
 

Saturday, July 25, 2020

New version 8.4.7 of ApPHP DataGrid Pro is released

The new version 8.4.7 of ApPHP DataGrid was released and available now for downloading. There are many improvements and new features. This version requires full re-installation, if you work with one of previous. Please read carefully Getting Started.

The goal of ApPHP DataGrid script is to simplify the generation and editing of DataGrid pages for web developers. It is a fully functional, outstanding open source PHP control.

To view a Live Demo click here.
To download new version click here.


Saturday, May 30, 2020

New product - Android mobile app for uBusinessDirectory released


We're happy to announce that Android mobile app for uBusinessDirectory has been released.
Almost everyone nowadays wants a mobile version of their website. Using our mobile appointment app will help your business to increase the revenue of business directory with ease. This is a truly hybrid mobile application for your business directory website, where you can reach your clients in real-time.
  • All the data will be displayed realtime.
  • Search listings and contact them on the go.
  • Works with businesses, private persons and other
Clients could download mobile app, install it and look for business listings directly form their mobile or tablet devices.
We also suggest a custom solution for your business, where you can change the logo of your company and other elements of the template and app.
Find more information here.

Saturday, May 16, 2020

New version 2.3.4 of uBusinessDirectory is released

New version 2.3.4 of uBusinessDirectory script has been released. uBusinessDirectory is one of the best one-size-fits-all solutions for creating Business Directory classified websites. This script allows to add categories, then associate added businesses to these categories. We provide you all things you need for a successful website such as: listings management, search engine friendly URLs, database backup, advanced text editor, banner rotation system etc. So it is really easy to start your own successful directory website. Listing owner has a complete control on listings in a real-time. See full list of changes here.

Wednesday, April 08, 2020

Laravel 6 - Creating Custom Form Request Validation


There is few ways to validate form submission data in Laravel.

The standard way is to use Validator facade in the beginning of your controller.
Lets see the example:

/**
 * Store a newly created resource in storage.
 *
 * @param \Illuminate\Http\Request $request
 *
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
  $validator = Validator::make($request->all(), [
    'title'  => 'required|min:5|max:200',
    'body_content'=> 'required|min:10',
    'blog_tag_id' => 'nullable',
  ],[
    'title.required' => trans('blog::alert.danger.reason.title_required'),
    'title.min'     => trans('blog::alert.danger.reason.title_min'),
    'title.max'      => trans('blog::alert.danger.reason.title_max'),
    'body_content.required' => trans('blog::alert.danger.reason.content_required'),
    'body_content.min' => trans('blog::alert.danger.reason.content_min'),
  ]);

  // ... next part of code after validation
}

In this example we perform validation inside the controller's action. It looks nice enough until you want to use the same code in another places: when you create a post in Backend or if you want to add a Unit tests. In such cases, you will copy-paste the same pieces of your code, that is not good, because you have to support all of them and such style of programming breaks DRY principle (Don't Repeat Yourself).

So... what the better way to implement such validation?
Laravel allows us to create our own Request class, instead of using a standard \Illuminate\Http\Request and use as a function parameter.

The first thing you have to do it to create such class.
Run following command:
$ php artisan make:request App\\Http\\Requests\\MyOwnRequest

This command will create MyOwnRequest request class in App\Http\Requests\ directory.
By default it will be looked as follow:


namespace App\Http\Requests\Auth;

use Illuminate\Foundation\Http\FormRequest;

class MyOwnRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return false;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            //
        ];
    }
}

Now you may move here your validation rules and replace Request parameter in store method with MyOwnRequest:

Your controller store method will be looking:

/**
 * Store a newly created resource in storage.
 *
 * @param \Illuminate\Http\MyOwnRequest $request
 *
 * @return \Illuminate\Http\Response
 */
public function store(MyOwnRequest $request)
{
 
  // ... next part of code after validation
}


MyOwnRequest class will be looking:
Remember to turn return value of authorize() method to TRUE!

namespace App\Http\Requests\Auth;

use Illuminate\Foundation\Http\FormRequest;

class MyOwnRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
           'title'  => 'required|min:5|max:200',
           'body_content'=> 'required|min:10',
           'blog_tag_id' => 'nullable',
        ];
    }
}

Looks much better, right? But what if you want to specify custom validate messages?
It's easy to implement with messages() method of your validator class. You simple have to define an array, where the key is a field name and the value is the custom message you want to show.
Let's see how to do this:


namespace App\Http\Requests\Auth;

use Illuminate\Foundation\Http\FormRequest;

class MyOwnRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
           'title'  => 'required|min:5|max:200',
           'body_content'=> 'required|min:10',
           'blog_tag_id' => 'nullable',
        ];
    }

    /**
     * Custom message for validation
     *
     * @return array
     */
    public function messages()
    {
        return [
         'title.required' => trans('blog::alert.danger.reason.title_required'),
         'title.min'     => trans('blog::alert.danger.reason.title_min'),
         'title.max'      => trans('blog::alert.danger.reason.title_max'),
         'body_content.required' => trans('blog::alert.danger.reason.content_required'),
         'body_content.min' => trans('blog::alert.danger.reason.content_min'),
        ];
    }
}

Ok, good. But what to do if you need to validate a set of fields, lets say: few checkboxes or few file fields? In this case you may use asterisk * to prepare validation rules. Check below how we define validation rules for set of fields. I hope it's clear and understandably enough.
public function rules(): array
{
   return [
      'files.*' => 'required|image|mimes:jpg,jpeg,png',
      'attrs.*.from' => 'nullable|numeric',
      'attrs.*.to' => 'nullable|numeric',
   ];
}

Laravel creates validation messages automatically, so sometimes you will need to provide a special names to your fields. You may use the following language lines are used to swap attribute place-holders with something more reader friendly such as E-Mail Address instead of "email" or indexes in array. This simply helps us make messages a little cleaner.
public function attributes(): array
{
   return [
      'receivers' => 'Nice name',
      'subject' => 'Like name',
      'body' => 'Another Name',
      'notify.blog.*' => 'Blog Notification value',
   ];
}

If you want to perform your own validation, you may use withValidator() method. It's useful when you need to perform additional or very complicated validation, after the main validation was passed (or not). In example below we check if an email presents in a list of pre-approved emails. Take in account, that there are some methods you may use:
$validator->after()
$validator->fails()
etc.

public function withValidator(Validator $validator)
{
   $email = $validator->getData()['email'] ?? '';
   $validator->after(
      function ($validator) use ($email) {
         if (is_null(\DB::table('pre_approved')->where('email',$email)->first())) {
            $validator->errors()->add(
               'email', 
               'This email does not exist on our pre-approved email list'
            );
         }
      }
   );       
}

As mentioned before, the form request class also contains an authorize method. You may check if the authenticated user actually has the authority to change a given resource. Lets see an example when user actually owns a blog comment and attempt to update it:

public function authorize()
{
   $comment = Comment::find($this->route('comment'));
   return $comment && $this->user()->can('update', $comment);
}
And the last thing, if you want to redefine a route  if validation fails, you may do this by redefining $redirectRoute property:
// The named route to redirect to if validation fails.
protected $redirectRoute = 'home';

Friday, April 03, 2020

Discount 40% Off! - Special 2020 Huge Spring Sale for ApPHP Members


Hi, everyone, here 2020 Huge Spring Sale!
Enjoy with a 40% Offer till 30 April 2020 ONLY!

Coupon Code: 2020-53DL-VZTH-UDR1


Enter this coupon code on checkout page and discount will be automatically applied to your order.



Valid on:
https://apphp.com
http://hotel-booking-script.com
http://business-directory-script.com

http://auto-dealers-script.com 
http://doctor-appointment-script.com
http://bid-auction-script.com 

Saturday, February 22, 2020

New version 1.3.2 of ApPHP MVC Framework is released

A new version 1.3.2 of ApPHP MVC Framework was released.

ApPHP MVC Framework is designed to provide modern and rapid development of websites, web applications and web services. It implements the the Model-View-Controller (MVC) design pattern and principles, including separation of display, logic, and data layers.

It provides an architecture, components and tools for developers to build a complex web applications faster and safer.

There are many changes and improvements in new version, including PHPUnit tests, new methods in CActiveRecord, CHttpRequest, etc. You can review all recent changes here.

Tuesday, January 14, 2020

New version 4.2.5 of ApPHP Shopping Cart is released

New version 4.2.5 of ApPHP Shopping Cart has been released and available now for downloading. This absolutely new script, based on ApPHP MVC Framework with many improvements and new features, like: adding to favorites, adding to comparison, new custom fields for products: color, weight, dimensions etc. All recent changes can be viewed here.

The script provides all necessary features including multi-currency and multi-language support. Visitors may view the contents of their shopping cart at any time and may add or delete items as needed. The program automatically calculates the subtotal, shipping charges, and total price. When a visitor decides to checkout, the order information is collected in database a receipt is sent to the shopper.

Last changes:
  • New added tabs & tags for products
  • New added manufacturer page with link to it from product description page
  • New added two types of gallery on product page
  • New added possibility to show/hide prices on Frontend
  • New added possibility to show/hide Add to Cart button on Frontend
  • New added possibility to show category images on Frontend
  • New added possibility to select product options from product description page
  • New added possibility to show images for product options
  • New added category description on category page on Frontend
  • New added possibility to add to cart the same product with different options
  • New added success payment page
  • New added order comments
  • New added is default field for the delivery settings
  • New ApPHP Framework updated to v1.2.2
  • New ApPHP Directy CMF updated to v3.0.2
  • New improved tags for products
  • New improved work of options
  • New added more information in the payment.log file for PayPal
  • New updated method of processing statuses for PayPal
  • New show country and state in the invoice
  • Fix bugs fixed
See Live Demo

Wednesday, December 11, 2019

45% Discount - 2019 End of Year Sales started!


Hi, everyone, here 2019 End of Year Sales!
Enjoy with a 45% Offer till 31 December 2019 ONLY!
Instantly if you order any product on ApPHP.com

Discount coupon: 2019-ENDY-I18H-TKHE

Valid on:
https://apphp.com
http://hotel-booking-script.com
http://business-directory-script.com

http://auto-dealers-script.com 
http://doctor-appointment-script.com
http://bid-auction-script.com 

Sunday, September 15, 2019

New product - uBidAuction script released!

uBidAuction is a powerful, scalable & fully-featured classic and bid auction software that lets create the ultimate profitable online auctions website. It allows to manage entire online auction operation: create new auctions within seconds, view members auctions and use the auction extension settings tool.

Our auction software uBidAuction will allow to setup comprehensive and robust site with two auction types: classic and regular big auction (user must buy bids to participate). Site administrator can adjust auctions time, step, bid increments, date formats, user authentication, graphic and other parameters in admin panel. Auction payments are via PayPal and it is possible to integrate another payment processor.

Wednesday, September 11, 2019

40% discount - 2019 Hot Autumn Sale started!





Hi, everyone, this 2019 Year is our Hot Autumn Sale!

Enjoy with a 40% Offer till 30 September 2018 ONLY!

Coupon Code:
2019-AUTM-560N-FEAB




Valid on:
https://apphp.com

uHotelBooking - hotel management, reservation and online booking system for all types of accommodations and hotel operations.
https://hotel-booking-script.com

 uBusinessDirectory - fully-featured web solution for business listings, classifieds directory and yellow pages website.

http://business-directory-script.com

uAutoDealers - fully-featured web solution for car dealerships and auto classified websites
http://auto-dealers-script.com

uDoctorAppontment - clinic management, doctor and therapist online medical appointment scheduling system for the management of health care appointments.
http://doctor-appointment-script.com

uBidAuction - PHP auction script, popular and cost effective solution to launch your Classic and Bid auctions website.
http://www.bid-auction-script.com

  

Wednesday, June 26, 2019

New version 2.2.1 of uDoctorAppointment is released

New version 2.2.1 of uDoctorAppointment has been released. uDoctorAppointment script is pursuing the on-demand trend in doctor appointment booking industry. This complete web-solution consists of a Patient area, Doctor area and Admin Dashboard. Instant delivery and guaranteed file download, encrypted secure order process and 100% open source code.  

This script allows doctors to register and select appropriate membership plan with different features. Patients can view doctor profiles before booking appointments. The site administrator or doctor may create and manage advanced schedules, create working time slots for each day of the week, define time off etc.

 Live Demo is here.

Saturday, May 25, 2019

The new version 8.3.9 of ApPHP DataGrid has been released

The new version 8.3.9 of ApPHP DataGrid was released and available now for downloading. There are many improvements and new features. This version requires full re-installation, if you work with one of previous. Please read carefully Getting Started.

The goal of ApPHP DataGrid script is to simplify the generation and editing of DataGrid pages for web developers. It is a fully functional, outstanding open source PHP control.

To view a Live Demo click here.
To download new version click here.


Saturday, May 18, 2019

Become a Seller on ApPHP CodeMarket!

Hi everyone! 

We're happy to announce that from now you may sell your products on our CodeMarket. Start to sell your awesome products today, upload creative designs and receive up to 70% for each sale. Get reviews from your users, set your own prices, track your sales and feedback on your products. 

Read more how to Become a Seller.