Max Allan Niklasson 3 Posted December 7, 2020 So I've been working on this module https://github.com/maxa11an/processwire-body-builder but then I decided to split it up into multiple files for better overlooking of the module it self. But when I try to install either MarkupBodyBuilder or ProcessBodyBuilder I end up with Allowed memory size of 2147483648 bytes exhausted (tried to allocate 262144 bytes) in .../wire/core/Modules.php on line 2480 Afaik I don't need a className-method, but then I studied through all docs regarding module-dev and also went through a lot of integrated modules, but no luck there. So I was hoping on some advise of what I've missed or things to think about? Share this post Link to post Share on other sites
kongondo 7,395 Posted December 7, 2020 (edited) @Max Allan Niklasson, Welcome to the forums. I just had a quick look but you are basically caught in an infinite loop with all those includes. You have this: In MarkupBodyBuilder.module <?php public function init() { include_once __DIR__ . "/vendor/autoload.php"; include_once __DIR__ . "/BodyBuilder.module";// <==== THIS $this->addHookAfter("Fields::save", $this, 'hookWhenFieldSaved'); $this->addHookAfter("Field::getInputfield", $this, 'hookHideTitle'); $this->addHookAfter('Page::renderField', $this, 'hookRenderField'); $this->twig = new Environment(new ArrayLoader(), [ 'autoescape' => false, 'debug' => $this->config->debug ]); $this->twig->addExtension(new DebugExtension()); return parent::init(); } In ProcessBodyBuilder.module <?php public function init() { include_once __DIR__ . "/BodyBuilder.module";// <==== THIS $process = $this->wire('process'); if ("$process" === "$this") { $this->headline($this->moduleInfo['page']['title']); } return parent::init(); } In BodyBuilder.module <?php namespace ProcessWire; use Exception; include_once "MarkupBodyBuilder.module";// <== THIS include_once "ProcessBodyBuilder.module";// <== THIS That is not how you reference other installed modules in ProcessWire; Call them like this where you need them: <?php // inside a class $bodyBuilder = $this->wire('modules')->get('BodyBuilder'); // outside a class // $bodyBuilder = $modules->get('BodyBuilder'); // outside a class but inside a function // $bodyBuilder = wire('modules')->get('BodyBuilder'); More info https://processwire.com/api/ref/module/ Edited December 7, 2020 by kongondo 1 Share this post Link to post Share on other sites
Max Allan Niklasson 3 Posted December 7, 2020 @kongondo thanks for your reply, I did as you mentioned but it didn't help. Although after some fresh air I went back and check the moduleInfo's requires parameters and it turned out that was what created the error, works smoothly now! 🙂 2 Share this post Link to post Share on other sites
kongondo 7,395 Posted December 7, 2020 4 minutes ago, Max Allan Niklasson said: works smoothly now! 🙂 Glad you got it sorted! 😀 Share this post Link to post Share on other sites