Skip to main content

Posts

Showing posts from August, 2025

PHP can run AI models - no need Python

 Objective:     Run AI models only using php. Now this is possible with  https://github.com/CodeWithKyrian/transformers-php  this library. I have tried object detection and question answering using this library. Technology:       1.  PHP 8.2 Initialization:     Guide -  https://transformers.codewithkyrian.com/getting-started 1. Initialize project by composer init cmd. 2. Install transformer library by  composer require codewithkyrian/transformers cmd. 3. Enable ffi extention in php.ini       extension = ffi      ffi.enable = true 4. Enable opcache      opcache.jit = tracing 5. Increase memory limit      memory_limit = 512M I. Object detection: ( https://transformers.codewithkyrian.com/object-detection )     Object detection can improve web application perspective . Example:  Retail applications can speed up checkout by automatically recognizing ...

Don't assign value to reference variable.

Objective:          I just tried to create linked list in php.  Challenges:     In php array is sufficient for most data types (simple array, multi-dimensional array and key-value associative array). But, i just tried using  stdClass Object ( pre-defined interfaces and class ). Here, I created one stdClass with reference key and it reference to another class up to final and that final class  reference key is null. Here I used reference key as reference variable. Once i started assigning reference value to this key it assigning new value to it and old one erased. $a = new stdClass(); $a->name = "Trial"; $a->ref = null; for($i=1;$i <= 10;$i++){  $b = new stdClass();  $b->name = 'Demo mj '.$i;  $b->ref = null;  if($a->ref === null ){   $a->ref = &$b;  }else{   $current = $a->ref;   wh...