Closed SilkeKohl closed 8 months ago
You should not use Controllers like that. It is a misuse. Controllers should be executed by the framework.
The reason why $this->twig
is null is because you did not call initController()
.
See the framework code to create a controller:
https://github.com/codeigniter4/CodeIgniter4/blob/813058769ac521625ec2cfd0212dc3f04d4e296d/system/CodeIgniter.php#L913-L918
I am very much asking for advice on how to resolve the following error: "Call to a member function render() on null."
This issue arises when calling it in the following manner:
Here's some additional information:
Controller and Method Behavior:
GetSystem
controller and itsgenStaticPage
method work correctly when used in the standard way.test/app/Config/Routes.php
:and then access
http://my-test.dev/gen_static.html
, everything functions as expected.Class Initialization and Variable Assignment:
BaseController
within theinitController
function and assigned to the variable:protected $twig;
.genStaticPage
function in theGetSystem
class:When called in the manner described in Info 1, it returns the complete data for the Twig class. However, when called in the way that triggers the error, it only returns
NULL NULL NULL NULL NULL NULL NULL
.MyEasyTaskScheduler Code Fragment: Below is a snippet from the MyEasyTaskScheduler library responsible for executing code:
Please help me with this problem.