Welcome Guest, Not a member yet? Register   Sign In
InitController and phpstorm navigation
#1

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
Reply
#2
Thumbs Up 

(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
Reply
#3

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->
    }

Reply
#4

(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->
    }

Reply




Theme © iAndrew 2016 - Forum software by © MyBB