Welcome Guest, Not a member yet? Register   Sign In
modifying BaseController.php for libraries
#1

(This post was last modified: 06-22-2023, 07:52 AM by richb201.)

I am trying to autoload libraries in BaseController.php. Is DoNotEditThisLine really just a comment?


public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
    {
        // Do Not Edit This Line
        parent::initController($request, $response, $logger);   <<this line is causing an error. Is this really just a comment?

        // Preload any models, libraries, etc, here.
        protected $libraries=[
        'grocery_CRUD',
        'email',
        'image_lib',
        'image_CRUD',
        'ftp',
        'form_validation'
    ];
    }
proof that an old dog can learn new tricks
Reply
#2

CodeIgniter 4 User Guide - CodeIgniter4 Overview Autoloading Files
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

You cannot remove the line "parent::initController($request, $response, $logger);".
If you do it, Controllers won't work.

You cannot use "protected" keyword in class methods in PHP.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB