I've taken a look at this question, but unfortuently there is no answer.
I'm using PhpStorm and I am building a project with a composer project loaded. I'm trying to make it so that PhpStorm recognises my classes/functions when I ctrl+click on them, specifically, for the projects installed via composer.
I have tried changing the
require __DIR__ . '/vendor/autoload.php';
Well ... technically that package has no
Braintree_Subscription class defined (I mean -- "proper" definition). Your 2nd screenshot shows definition of
Subscription class from
Notice the very last line -- that "undefined" class is mentioned there when calling
It looks like your PhpStorm does not understand such class definition.
Here is the ticket from PhpStorm's Issue Tracker: WI-11936 -- accordingly to the ticket it has been fixed on 3rd of November 2016 (2 days ago, basically). The fix (class alias support) will be available in next major version, which is 2016.3.
You may wait till it will be officially released (approximately end of the month) or try next EAP or RC build (watch their blog or twitter for announcements).
Right now (for current and past stable versions: 2016.2 and older) the solution is to use "real" class name (
\Braintree\Subscription) instead of alias (
Braintree_Subscription) in your code.
But in any case: using real class in your own fresh code name is the most correct way -- leave class aliases for situation where some legacy/compatibility support is required and other edge cases.
P.S. This has nothing to do with Composer -- nothing at all.
It's just the code examples -- for whatever reason (possibly legacy/compatibility reasons .. or easier for new to PHP users, do not know) they are using class aliases instead of real class names and PhpStorm does not understand such aliases.