Hi, I'm trying to create objects on the run, but it I have run int a barrier that is really annoying: The code is:
$tableName = $this->_stripNamespaceFromClassName(get_class($this));
$modelName = $tableName;
$modelName[strlen($modelName) - 1] = "";
$demoModelName = "Product";
echo "-".$tableName."-\n";
echo "-".$modelName."-\n";
echo "-".$demoModelName."-\n";
$demoFullyQualifiedModelName = "\\StreamComposer\\Models\\$demoModelName";
$fullyQualifiedModelName = "\\StreamComposer\\Models\\$modelName";
echo "So far so good\n";
new $demoFullyQualifiedModelName();
echo "Demo loaded ok\n";
new $fullyQualifiedModelName();
echo "Fully loaded ok\n";
The result is (Echo string is bold): -Products- -Product- -Product- So far so good Demo loaded ok PHP Fatal error: Uncaught Error: Class '\StreamComposer\Models\Product' not found in /var/www/streamcomposer.com/api/Models/Repositories/Repository.php:61 Stack trace: #0 /var/www/streamcomposer.com/api/Command/setupPayment.php(27): StreamComposer\Models\Repositories\Repository->loadAll() #1 /var/www/streamcomposer.com/api/Command/setupPayment.php(32): StreamComposer\Command\SetupPayment->createPlans() #2 {main} thrown in /var/www/streamcomposer.com/api/Models/Repositories/Repository.php on line 61 As you see the $demo.. object loads fine, but the $fully.. does not :-( Thanks in advance