kleninmaxim's avatar

Fix an undefined class in phpstorm

Hi everyone!

I have a class. In PhpStorm I see Undefined namespace 'Aeron' Undefined class 'Publisher'

<?php

namespace Src;

use Aeron\Publisher;
use Memcached;

class Test
{

}

In comsoer.json I have "ext-memcached": "*"

When I click to Memcached Class I go to memcached.php file (C:\Program Files\JetBrains\PhpStorm 2021.3.1\plugins\php\lib\php.jar!\stubs\memcached\memcached.php):

<?php

// Start of memcached v.3.1.5
use JetBrains\PhpStorm\Deprecated;

/**
 * Represents a connection to a set of memcached servers.
 * @link https://php.net/manual/en/class.memcached.php
 */
class Memcached
{
....

I can use class Memcached and all functions.

How I can do it with Aeron\Publisher and I use one more class Aeron\Subscriber?

  • Classes Aeron\Publisher and Aeron\Subscriber are work. PhpStorm doesn't see them.
  • Additional. In file: /etc/php/8.0/mods-available/aeron.ini I have extension=aeron.so

Thanks.

0 likes
1 reply
bobbybouwmann's avatar

You need to add the class-map to your composer.json. If it is a package it should be part of the composer.jsonof that package. If you're running your own custom directory with code you need to add the autoload to your owncomposer.json` like so

"autoload": {
	"psr-4": {
        "Aeron\\": "aeron/",
		"App\\": "app/",
		"Database\\Factories\\": "database/factories/",	
		"Database\\Seeders\\": "database/seeders/"
	}
}

Of course this needs to be the correct directory for you.

Please or to participate in this conversation.