Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

about DI integration other base class

How do I integrate the DI Class in other base class file ?

<?php

namespace Phalcon\Engines;


class Logic extends \Phalcon\DI\Injectable
{

    public function __construct()
    {

    }

}

for example : in Controll class , i can use $this->session or $this->request .

<?php

namespace Phalcon\Engines;

use Phalcon\Mvc\Controller as MvcController;

class Controller extends MvcController
{
    public $_request_session = true;


}

how can I use $this->session or $this->request in Logic class .

My English general.Say not clear

thks.

You can also extend this class: Phalcon\Mvc\User\Component http://docs.phalconphp.com/en/latest/api/Phalcon%5Mvc%5User%5Component.html

How can i get DI attribute in the Logic class ? i extends Phalcon\Mvc\User\Component in Logic class, but this result object(User\Logics\SessionLogic)[64] protected &#039;_di&#039; => null protected &#039;_dependencyInjector&#039; => null protected &#039;_eventsManager&#039; => null is null



1.5k
Accepted
answer
$di->set("sessionlogic", "SessionLogic");

$loader->registerDir(
    ["your/path" => "your/path/sessionlogic"]
);

or

$loader->registerNameSpace(
    ["your/namespace" => "your/path/sessionlogic"]
);

thank you. issue this problem.

```php $di->set("sessionlogic", "SessionLogic");

$loader->registerDir( ["your/path" => "your/path/sessionlogic"] );

or

$loader->registerNameSpace( ["your/namespace" => "your/path/sessionlogic"] ); ```