Answer the question
In order to leave comments, you need to log in
How to include nested classes when running via PHP CLI?
I call the script from the console php /var/www/myFile.php
In it, I connect the class using this code (found on the internet)
function classes($class)
{
$app = dirname(__DIR__);
$class = str_replace('app\\', '', $class);
$file = $app . "/" . str_replace("\\", "/", $class) . ".php";
if (file_exists($file)) {
require_once $file;
}
}
spl_autoload_register('classes');
function classes($class)
{
$app = dirname(__DIR__);
$class = str_replace('app\\', '', $class);
$file = $app . "/" . str_replace("\\", "/", $class) . ".php";
if (file_exists($file)) {
require_once $file;
}
}
spl_autoload_register('classes');
// /var/www/www-root/data/www/dev.goti.ru/app/components/Xml.php
$class = new Class();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question