hansolobg Posted December 31, 2019 Share Posted December 31, 2019 Hello I'm new to Processwire. I'm starting to build a platform. I want to separate some of my logic into the site/src folder. I added a simple tester class inside the site/src folder: site/src/Helper.php <?php namespace test; /** * In this class all usefull helper functions are aggregated. */ class Helper { public static function test() { return "hello"; } } Then I want to use those functions e.g. in the template folder. I use them as the following: site/templates/home.php <?php namespace ProcessWire; use test\Helper; $test = Helper::test(); ?> Now I get the following error: Fatal Error: Uncaught Error: Class 'test\Helper' not found in /var/www/html/site/templates/home.php:5 Stack trace: #0 /var/www/html/wire/core/TemplateFile.php(287): require() #1 /var/www/html/wire/core/Wire.php(380): ProcessWire\TemplateFile->___render() #2 /var/www/html/wire/core/WireHooks.php(723): ProcessWire\Wire->_callMethod('___render', Array) #3 /var/www/html/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\TemplateFile), 'render', Array) #4 /var/www/html/wire/modules/PageRender.module(514): ProcessWire\Wire->__call('render', Array) #5 /var/www/html/wire/core/Wire.php(383): ProcessWire\PageRender->___renderPage(Object(ProcessWire\HookEvent)) #6 /var/www/html/wire/core/WireHooks.php(723): ProcessWire\Wire->_callMethod('___renderPage', Array) #7 /var/www/html/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\PageRender), 'renderPage', Array) #8 /var/www/html/wire/core/WireHooks.php(822): ProcessWire\Wire->__call('renderPage', Array) #9 /var/www/html/wire/core/Wire.p (line 5 of /var/www/html/site/templates/home.php) What am I doing wrong here? Link to comment Share on other sites More sharing options...
Zeka Posted December 31, 2019 Share Posted December 31, 2019 @hansolobg Did you include your class file? Link to comment Share on other sites More sharing options...
hansolobg Posted December 31, 2019 Author Share Posted December 31, 2019 I missed to include the /src path into the composer.json autoload path. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now