I am trying to use custom classes globally, so i setup a TestClass.php with a public test function() returning a simple string.
Just for testing before i can continue.
For this to work i created a folder with php file in: “packages/fishueel_package/src/TestClass/TestClass.php”
The code looks like:
<?php
namespace Concrete\Package\FishueelPackage\Src\TestClass;
class TestClass {
public function test() {
return "Test";
}
}
?>
And from another file, inside:
“packages/fishueel_package/themes/fishueel”
I try to get/use the class using:
use \Concrete\Package\FishueelPackage\Src\TestClass\TestClass;
$testVar = TestClass::test();
But everytime i try to use it like the code above i get an error: “HTTP ERROR 500”
I searched the forums and google hoping to find a solution, but without succes.
Could anyone help me out, i thought this would be a bit easier after reading several posts online on stackoverflow.
Change the namespace in the folder/class: “packages/fishueel_package/src/TestClass/TestClass.php”
from: “namespace Concrete\Package\FishueelPackage\Src\TestClass;”
to: “TestClass”
And place the function:
public function on_start()
{
$listener = \TestClass();
$listener->addListeners(); //is this a Concrete function?
}
In the controller.php of the package as well, however whenever i insert the on_start() function its giving me the error: “Call to undefined function TestClass()”
And without the on_start() function, i still cant seem to get variables or call the class from another file.