Lost email template loading in custom file

Hi,

code from 2024 worked, now in 2025 seems to have lost ability to load an email template…
note this is a custom file.

this is the header

namespace PHPMaker2025\dams;

use DI\ContainerBuilder;

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

// Require files
require_once "../src/constants.php";
require_once "../src/config.php";
require_once "../src/phpfn.php";
require_once "../src/userfn.php";

$containerBuilder = new ContainerBuilder();
$containerBuilder->useAttributes(true);

// Add definitions
$containerBuilder->addDefinitions("../src/definitions.php");

// Dispatch container build event
DispatchEvent(new ContainerBuildEvent($containerBuilder), ContainerBuildEvent::NAME);

// Build PHP-DI container instance
$container = $containerBuilder->build();

HP Fatal error: Uncaught Slim\Views\Exception\PhpTemplateNotFoundException: View cannot render “NotifyCampaignEnding.en-US.php” because the template does not exist in vendor/slim/php-view/src/PhpRenderer.php:176

is there an email container that we need to create?

this is the pertinent code. (some removed for clarity)

    function _sendCampaignExpiring($row, $args) {
        $GLOBALS["RELATIVE_PATH"] = "../";
        
        $email = new Email();
        $email->Format = "html";      
        $msg_template = 'NotifyCampaignEnding.php';
        
       
        $email->load($msg_template, data: [
            "From" => Config("SENDER_EMAIL"), // Replace Sender
            "To" => $recipient, // Replace Recipient
            "Cc" => $Cc, 
            "Subject" => $subject,  // Replace Subject
            "campaign_ends" => $campaign_ends,
            "campaign_name" => $campaign_name,
            "document_name" => $document_name,
            "dt" => $dt
        ]);          
}

works perfectly fine in v2024.

this is the 2024 header

namespace PHPMaker2024\dams;

use PHPMaker2024\dams\{UserProfile, Language, AdvancedSecurity, Timer, HttpErrorHandler, RouteAttributes, SessionHandler};
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Container\ContainerInterface;
use DI\Container as Container;
use DI\ContainerBuilder;
use Slim\Factory\AppFactory;
use Slim\Factory\ServerRequestCreatorFactory;
use Slim\Exception\HttpInternalServerErrorException;
use Middlewares\Whoops;
use Dflydev\DotAccessData\Data;
use Selective\SameSiteCookie\SameSiteSessionMiddleware;

use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Connection;

require_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";

    $containerBuilder = new ContainerBuilder();
    $containerBuilder->useAttributes(true);
    $containerBuilder->addDefinitions("../src/definitions.php");    
    $container = $containerBuilder->build();           

thanks,
JS

Make sure you have already had “NotifyCampaignEnding.en-US.php” file inside the generated “lang” folder.

its there my friend, nothing changed from our v2024 version…

Check the language folder being used (e.g. var_dump($email->LanguageFolder)) and adjust as necessary.

not sure this makes sense…

string(33) “C:\xampp\htdocs\dams\src/…/lang/”

tried to set various ways, but still cannot find…

    $email->LanguageFolder = "lang";
    $msg_template = 'NotifyCampaignEnding.php';

also tried
$email->LanguageFolder = “…/lang”;
$email->LanguageFolder = “./lang”;
$email->LanguageFolder = “C:/xampp/htdocs/dams/lang”;

still comes back with:
“NotifyCampaignEnding.en-US.php” because the template does not exist in C:\xampp\htdocs\dams\vendor\slim\php-view\src\PhpRenderer.php:176

which is:
if (!$this->templateExists($template)) {
throw new PhpTemplateNotFoundException(
‘View cannot render "’ . $template . ‘" because the template does not exist’
);
$template = NotifyCampaignEnding.en-US.php

if it gets to the phpRenderer stage, then it language folder specified exists
which is:
$email->LanguageFolder = “…/lang/”;

and it doesn’t matter which template i use, it fails with every one of them…

this file/code was working perfectly fine in 2021-2024 versions, nothing changed.

Again this is why you should not use standalone scripts anymore. If you still do that, you need to include required scripts and make sure the relative paths are correct yourself. If you just want to send an email with your custom file, you better use Route_Action server event and make sure your template has language ID that matches your language(s) of your project (e.g. NotifyCampaignEnding.en-US.php) and is placed in the “lang” folder correctly.

the reason these files are outside of the phpM generation is because they need to run from the CLI, which the generated files won’t.
just trying to take advantage of whatever classes are available.

for the email template load, we reverted back to the previous methods
$email->Content = file_get_contents($msg_template);
$email->ReplaceContent(“”, $value);

works for now, the only issue is the getting the current language id fails.

You may use cURL via CLI to run your route or APi actions.

You might want to use this: How to Load Data from Database into Custom Files (v2025) - #11 by mobhar