How can i prevent from creating multiple instances in Codeigniter?

Viewed 50

I am new on Codeigniter and i have a question. In controller classes i need to use session, request and validation objects in every method So for each method i have to create an instance of them like below:

$session=\Config\Services::session();
$validation=\Config\Services::validation();
$request=\Config\Services::request();

How can i make one instance for whole the controller methods? I tried to creat property but it seems that i can not use an object as a property I would be thankful if you help me with that

1 Answers

Make them globals - some suggestions of different approaches for how to achieve this in this thread

Related