CodeIgniter Forums
InitController and phpstorm navigation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10)
+--- Thread: InitController and phpstorm navigation (/showthread.php?tid=86854)



InitController and phpstorm navigation - Kris40 - 02-21-2023

Hello,

I'm using the new constructor initController instead of the php __construct, but i have some problems to navigate through the models with phpstorm :
With the old __construct, doing this :
public $my_model;
function __construct()
{

$this->my_model          = model('\App\Models\my_model');
}
i could navigate through the models
Replacing with the new initcontroller make navigation impossible. I tried using phpdoc tags @var \App\Models\my_model but no effects
Does someone have the same problems ?
Best regards


RE: InitController and phpstorm navigation - Kris40 - 02-25-2023

(02-21-2023, 02:49 AM)Finaly i solved my problem by just adding the missing type :public '\App\Models\my_model' $my_model;now phpstorm can navigate through the modelsKris40 Wrote: Hello,

I'm using the new constructor initController instead of the php __construct, but i have some problems to navigate through the models with phpstorm :
With the old __construct, doing this :
public $my_model;
function __construct()
{

$this->my_model          = model('\App\Models\my_model');
}
i could navigate through the models
Replacing with the new initcontroller make navigation impossible. I tried using phpdoc tags @var \App\Models\my_model but no effects
Does someone have the same problems ?
Best regards



RE: InitController and phpstorm navigation - kenjis - 02-25-2023

This works.
But it may be better to set the type for $myModel like private MyModel $myModel;


PHP Code:
<?php

namespace App\Controllers;

use 
App\Models\MyModel;
use 
CodeIgniter\HTTP\RequestInterface;
use 
CodeIgniter\HTTP\ResponseInterface;
use 
Psr\Log\LoggerInterface;

class 
Home extends BaseController
{
    private $myModel;

    public function initController(
        RequestInterface $request,
        ResponseInterface $response,
        LoggerInterface $logger
    
) {
        parent::initController($request$response$logger);

        $this->myModel model(MyModel::class);
    }

    public function index()
    {
        $this->myModel->
    }




RE: InitController and phpstorm navigation - Kris40 - 02-27-2023

(02-25-2023, 05:48 AM)You're right, it's better, but  when trying to find methods in Wrote:
PHP Code:
$this->myModel-> i can't find anything with phpstorm
Maybe i'
m missing sometingi'll try one more time with you response with a lot of coffee...
Thanks for your answer 


kenjisThis works.
But it may be better to set the type for $myModel like private MyModel $myModel;


PHP Code:
<?php

namespace App\Controllers;

use 
App\Models\MyModel;
use 
CodeIgniter\HTTP\RequestInterface;
use 
CodeIgniter\HTTP\ResponseInterface;
use 
Psr\Log\LoggerInterface;

class 
Home extends BaseController
{
    private $myModel;

    public function initController(
        RequestInterface $request,
        ResponseInterface $response,
        LoggerInterface $logger
    
) {
        parent::initController($request$response$logger);

        $this->myModel model(MyModel::class);
    }

    public function index()
    {
        $this->myModel->
    }