Welcome Guest, Not a member yet? Register   Sign In
How to use suggestions and find usage with PHPStorm
#1

Hello!

I use PHPStorm and since my code becomes more complex, I miss the suggestions if I want to use a model, I can't see my docs if I use a method and also in the model file all methods are grey, which means, they aren't ins use, witch also means, I can't refactor if necessary. Let me show you what I have at the moment:

First of all, I use a BaseModel, where I have some db-request, which I use in several models. The crtSlug() here I can refactor and I find all usage if I search.

PHP Code:
namespace App\Models;

use 
CodeIgniter\Model;

class 
BaseModel extends Model
{

    public function crtSlug(string $name): string
    
{
        /* Fancy stuff here */
    }



Then, SubjectModel extend BaseModel mostly. Not all, some extends the CI-model like above. crtForm() is grey, I can't find usage.

PHP Code:
namespace App\Models;

use 
CodeIgniter\Model;
use 
App\Models\BaseModel;

class 
SubjectModel extends BaseModel
{

    protected $table        'subjects';
    protected $primaryKey    'id';
    protected $returnType    'object';
    protected $allowedFields = ['id''slug''type''name''description'];

    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    public function crtForm($data NULL): array
    {
        /* hold all data for my forms */
    }


What I also do is, to load my models in the BaseController. The very most stuff is need on every page, is it for the navigation or something else.

PHP Code:
namespace App\Controllers;

use 
CodeIgniter\Controller;
use 
CodeIgniter\HTTP\CLIRequest;
use 
CodeIgniter\HTTP\IncomingRequest;
use 
CodeIgniter\HTTP\RequestInterface;
use 
CodeIgniter\HTTP\ResponseInterface;
use 
Psr\Log\LoggerInterface;

class 
BaseController extends Controller
{
    protected $request;

    protected $ionAuth;
    protected $subject;
    protected $timeline;

    public function initController(RequestInterface $requestResponseInterface $responseLoggerInterface $logger)
    {
        parent::initController($request$response$logger);

        // Loading things
        $this->ionAuth  = new \IonAuth\Libraries\IonAuth();
        $this->subject  = new \App\Models\SubjectModel();
        $this->timeline = new \App\Models\TimelineModel();

        // if logged in...
        if ($this->ionAuth->loggedIn() == '1')
        {
            /* one of the reasons to make use of the base controller :) */
        }
    }


And this are normal controllers. Here I can auto complete $this->subject but nothing more. I can't see the methods, which are in the subjectModel. Also, you see "timelineModel" above, which only extends Model. This is the basic structure and this one works well weeks ago. But nor yet anymore :/

PHP Code:
namespace App\Controllers;

use 
CodeIgniter\Model;
use 
App\Controllers\BaseController;

class 
Subject extends BaseController
{
    public function index()
    {
        $this->subject->crtSlug();
    }



So, can anyone help me to write the code better or configure PHPStorm to use the alluded features. Thank you Smile
Reply
#2

(This post was last modified: 11-01-2021, 04:55 AM by kenjis.)

It seems strange.
I can auto complete $this->subject->

[Image: 2021-11-01-20-41-33.png]
Reply
#3

Hmm... Strange. It work here only on the BaseController. There I have the suggestions and I can find the usage when I search for it. It seems, that any kind of a link between the BaseController and the normal controllers are not working. I cleared any cache in the meantime and run code inspections, but without any effect.
Reply
#4

Works here also.
What did you Try? What did you Get? What did you Expect?

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

Okay, it is not because of the structure of CI and it is more my system like the configuration or what so ever :/ If I found a solution, I will post it.

Thank you!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB