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


Messages In This Thread
How to use suggestions and find usage with PHPStorm - by sprhld - 11-01-2021, 03:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB