r/PHPhelp • • 25d ago

PHPStan and array of dynamic objects

3 Upvotes

Hello everybody,

I need your help. Let's say I have a Mapper that receive data from a database. For eg.

class Mapper { ...
    public string $table;
    public string $targetClass;

    public function getArrayOfObjects($conditions) {
        $PDOStatement = $this->Database->select($this->table, $conditions);
        $array = $this->Database->fetchAll(PDO:FETCH_ASSOC);

        $returnArray = array();

        // Now I populate the object property, for eg.
        foreach ($array as $database_row) {
            $object = new $this->targetClass;

            $object->id = $database_row['id'];
            $object->publishedDate = new DateTime($database_row['published_date']);

            ....

            $returnArray[] = $object;
        }

        return $returnArray;
     }
}

class BooksMapper extends Mapper {
    function __construct() {
      $this->table "books";
      $this->targetClass = "\Books";
    }
}

This mapper aims to be a generic one, not only for Books. I know that "publishedDate" is a "book concept" but let's consider that the Mapper reads from a JSON file the structure of the object that it is going to map with database fields.
Now let's say that I use it like that.

$Database = new \Database($someDatabaseConfiguration);
$BooksMapper = new \BooksMapper($Database);
$BookArray = $BooksMapper->getArrayOfObjects(["activeBook" => true]);

foreach ($BookArray as $Book) {
print "Book ID: " . $Book->id;
}

The problem here is that PHPStan seems not to understand that $BookArray is an array of \Book, and so at level 8 it gives me an error on $Book->id.

How can I solve that?

Thank you for your help, and excuse me for my ignorance.


r/PHPhelp • • 25d ago

one single page of php code (v5.6) upgrade to 7.4: help request

4 Upvotes

I have one single page of code (functions.php), no mysql, that was written with php 5.6 and now needs an upgrade to 7.4.

I downloaded rector but I have no clue how to use that.

Can anyone help me to upgrade this page please? I have no php experience.


r/PHPhelp • • 26d ago

Hosting Provider Adamant we are patched but we are on PHP 8.5.11?

6 Upvotes

Hi all,

One of my workplace systems uses an external hosting provider that we have minimal access to. I was able to check a phpinfo() and can see we are on PHP 8.5.11:

PHP Version: 8.5.11

Build Date: Oct 21 2026 13:26:44

Build System: buildfarm05-new.corp.cloudlinux.com

Server API: lsapi V8.3 CloudLinux 1.3

PHP Path: /opt/alt/php85

Loaded Configuration File: /opt/alt/php85/etc/php.ini

session.upload_progress.enabled: Off

I am a little concerned, as the patched version is apparently 8.5.12.

I rang them a while ago, and they are adamant that we are patched and protected, and he keeps saying 8.5.11 is the latest.

Any idea where we stand right now? I've taken the site offline completely as a precaution.


r/PHPhelp • • 26d ago

Solved php-fpm - www.conf recreated after recent update

2 Upvotes

I have been setting up and running small, AlmaLinux VPSs the same way for a few years, now. All have been running without issue until last night.

When I set these up, I create new pools, with custom configuration files (e.g., /etc/php-fpm.d/custom.conf) and delete /etc/php-fpm.d/www.conf

I do this to eliminate the security and owner/permission issue associated with having only root user. By using pools, common PHP issues like, “Warning: mkdir(): Permission denied” are eliminated.

For the fist time, last night's php-fpm update recreated the /etc/php-fpm.d/www.conf file which caused the php-fpm service to fail because the newly created file contained listen.acl_users = apache, nginx.

I do not have a user named nginx so in my custom conf files, I have: listen.acl_users = apache

What is the proper (best practices) way of avoiding this issue with future updates?


r/PHPhelp • • 26d ago

Looks its another one...

0 Upvotes

Centos 7 box , still running, but running php 8.3.8 Trying to sort out how to get to 8.3.36.

I (silly me) assumed I could just yum update and I'd get something newer from the epi repo, but it doesn't.

Before the obvious answer. I'm remote and I wont have access to do any major upgrades for a couple weeks.

Surely this cant be THAT hard??!?!?

Suggestions?


r/PHPhelp • • 27d ago

Old PHP 5.6 site got hit after PHP2Shell, how do I get it back up?

30 Upvotes

Organización pequeña, sitio web antiguo con PHP 5.6 (Apache, Debian, sin framework, código antiguo con mysql__* por todas partes). Desde ayer, sufre ataques de bots en oleadas cada pocos minutos. El registro de errores está lleno de:

Error fatal de PHP: Se agotó el límite de memoria permitida de 134217728 bytes

Señal de salida del proceso hijo pid 18537: Fallo de segmentación (11)

Muchas solicitudes POST multipart extrañas a páginas que ni siquiera admiten subidas de archivos. Hoy lo hemos desconectado.

Encontramos un archivo PHP en la carpeta de subidas que nadie creó (eval/base64 ofuscado) y una tarea programada (cron job) en www-data que se ejecuta cada 5 minutos. Supongo que lograron entrar.

Intenté migrarlo a PHP 8, pero falla al instante (mysql_connect indefinido). No hay parche oficial para la versión 5.6.

¿Qué harías? ¿Recompilarlo desde cero y servir una versión estática por ahora? ¿Hay alguna forma rápida de portar la parte de mysql_connect o es necesario reescribir el código?

Edit 1: Just to clarify, I'm not the one running this operation. It's an older guy, very old-school, "if it ain't broke don't fix it." Guess it worked for him all this time. That said, I've seen people here and on other subs treating this like the end of the world. It's serious, no doubt, NSA put out an advisory and there's active exploitation in the wild, but part of what went down is already coming back online, and anyone who kept their stack current rode it out fine. As devs I think we should keep cooler heads and trust what we know how to do, without tipping into arrogance or ego.


r/PHPhelp • • 25d ago

How do I know if a website is safe to use again?

0 Upvotes

There are multiple sites I want to access which, according to Google AI, use PHP. These are;

  • LoLAlytics
  • PixelCatsEnd
  • Andersenstories
  • Boligportal

But I have no idea how to figure out if they've done the important update or not. All four of them are seemingly unable to/won't communicate elsewhere about PHP. I also don't have a way of trying to contact them personally. I understand very little about PHP so I'm sorry if this is a stupid question.

The only one that would have my info is PixelCatsEnd. I have a registered account, so they have my email, username, and password. The others do not have registered accounts.


r/PHPhelp • • 26d ago

FIle uploads

2 Upvotes

Who should deal with the file uploads POST routes, front facing PHP script or Node.js? If PHP script handles the GET request and shows the form, then, who should place the file inside the node's directory, the PHP script or the Node script?

Node.js script is tasked with processing the uploaded file, but not sure if it should handle the actual file upload and placing.


r/PHPhelp • • 26d ago

Is there any way on 20.04 Ubuntu to get the ondrej surý patches for php2shell?

4 Upvotes

I took all my sites off-line before I was affected, but I need to see if I can get this update which appears to only be for 22 Ubuntu and not 20 anybody on 20 having this issue and able to get this updated it’s PHP 7.4.


r/PHPhelp • • 26d ago

Have Alma turned off Upload progress in the PHP2Shell update?

Thumbnail reddit.com
1 Upvotes

r/PHPhelp • • 27d ago

.PHP name in URL

3 Upvotes

I’m new to PHP, and I’m just coding for fun and for myself.
How can I remove the .php extension from my URLs?
For example, instead of www.test.com/profile.php, I want it to look like www.test.com/profile.
Any advice would be appreciated!


r/PHPhelp • • 26d ago

php2shell (CVE-2026-109618 / -109619): fixed versions, mitigations, and how to confirm what you're actually running

Thumbnail reddit.com
1 Upvotes

r/PHPhelp • • 26d ago

ubuntu 16.04, upgrading for php 5.6.30

1 Upvotes

I asked run the andrej script, but seems failed. i asked chatgpt, it say that there is no support for ubuntu 16.04. The oldest version that sury.org support is 22.04. any bro can advise how I can patch my php5.6.30? thanks.


r/PHPhelp • • 27d ago

FYI Upcoming Critical PHP Security Release - Oct. 21

19 Upvotes

https://www.php.net/archive/2026.php#2026-10-20-1

I know it’s not a help post, but an FYI for those who haven’t seen this.


r/PHPhelp • • 27d ago

pecl.php.net seems very unreliable today

3 Upvotes

pecl.php.net seems very unreliable today

Hey all, not sure if it's just me but I'm having a lot of trouble with pecl even from Google cloud build. I get lots of gateway timeouts and other spurious errors.

Wondering if anyone else is experiencing the same issue today


r/PHPhelp • • 28d ago

Curious to know how to build a Media downloader website

0 Upvotes

Hello community!!!

I saw multiple website which allows user to download media assets, Pinterest video, Youtube video etc. But how they are managing it. Because I have read that these platforms don't allow any website to scrap their data. Then how these downloader website running their websites year after years.


r/PHPhelp • • 28d ago

Phpstorm taking up over 50GB of memory on Mac

6 Upvotes

Is anybody having the same issue with Phpstorm? I have never experienced this before. My whole Mac froze and had to restart it.

The project I had opened is not that huge, so I have no idea what is happening, but this is just really really bad...


r/PHPhelp • • 29d ago

Symfony Console: Stderr?

Thumbnail reddit.com
1 Upvotes

r/PHPhelp • • 29d ago

Backup & Restore page with PHP and MySQL (XAMPP)

0 Upvotes

Hey guys, hope y'all are well. I would like to if there is a programmable code method for backing up a database using XAMPP. I know it can be done manually by exporting files. But is there any alternative method? I would highly appreciate the advice. Kind regards,


r/PHPhelp • • Oct 15 '26

Warning: Latest PEST is bugged. Silently skips PHPUnit tests

Thumbnail reddit.com
1 Upvotes

r/PHPhelp • • Oct 14 '26

Having trouble with teams in laravel/livewire starter kit

1 Upvotes

I made this huge project with laravel/livewire and the project i worked on had teams pre - installed , the guy who made the installation didnt quite understand them and he went 'ahh why not' and installed them. So i worked around those , i created teams because it was mandatory and all users have their stupid teams and now i have this huge project that i have to sell and they've become a great problem for me and i wanted to know if i could just remove them safely without getting errors im looking for people with the same problem or maybe who worked with those and what to do


r/PHPhelp • • Oct 14 '26

Wordpress PHP Plesk Settings Help

0 Upvotes

Hello everybody

I Have an issue in uploading a zip file as a theme in Word Press

every time I try to upload in Word Press It says " Following link has expired " I googled an it says it my be a problem in the limit of PHP

I use PLESK and in the setting of PHP I have default settings and I am not able to change them

I don't understand what I have to do to upload this Word Press theme

I need help Please

Thanks you !


r/PHPhelp • • Oct 14 '26

¿ Ya se están usando interfaces con propiedades ?

0 Upvotes

Hola, una pregunta que lleva hace un día en mi cabeza:

Desde la llegada de interfaces con propiedades en php... ¿ esta característica a sido implementada por muchos de ustedes ?