Running CLI PHP scripts

I use a lot of CLI PHP scripts to perform simple database operations on PHPMaker applications, usually running as cron jobs (or scheduled tasks in Windows). However, I want them using the same configuration from the web application, so I start my scripts by changing folders to the web application’s and loading configs and dependencies from there.
This is an working example in v2024:

namespace PHPMaker2024\MY_APPLICATION;

use Dflydev\DotAccessData\Data;

$WebRootPath = "C:/Inetpub/wwwroot/";
chdir($WebRootPath);

// Relative path
$RELATIVE_PATH = "";

// Autoload
include_once "vendor/autoload.php";

// Require files
require_once "src/constants.php";
require_once "src/config.php";
require_once "src/phpfn.php";
$ConfigData = new Data($CONFIG); // Ensure that $ConfigData is accessible by Global Codes
require_once "src/userfn.php";

$sql = "SELECT * FROM my_table";
$rs = ExecuteQuery($sql)->fetchAll();

I’m struggling to make it work in v2025. Of course, I updated the namespace to PHPMaker2025\MY_APPLICATION. Yet, I’m still getting this error:

Fatal error: Uncaught TypeError: PHPMaker2025\MY_APPLICATION\Conn(): Return value must be of type Doctrine\DBAL\Connection, null returned in C:\inetpub\wwwroot\src\phpfn.php:1985

What do I need to add into my script to make this work in v2025?

You may follow this post: How to Load Data from Database into Custom Files (v2025) - #2 by mobhar

Brilliant, thanks so much!
Actually, I found that $stmt->rowCount() kept returning -1 (using SQL Server, don’t know if that’s a factor).
So I changed this

$stmt = ExecuteQuery($sql);
if ($stmt->rowCount() > 0) {
    while ($row = $stmt->fetchAssociative()) {

into this

$stmt = ExecuteQuery($sql)->fetchAllAssociative();
if (count($stmt) > 0) {
    foreach ($stmt as $row) {

which gave me a count of 7, the right count for my query, and everything worked fine!
Anyway, thanks again!