Skip to content

PHP0413 Error (Unknown Class) for symlinked packages #684

@julesgilson

Description

@julesgilson

Intellisense is always showing "unknown class" PHP0413 for composer packages installed from local repo. Unsure if this is because composer creates a symlink in ./vendor/publisher/ to the package or for another reason.

Note: This is on Windows - symlinks on *nix systems may not have the same issue - if it is a link issue.

Re-importing the class fixes the issue until VSC is restarted - where the problem returns. Quite tedious as the package is used in many other classes...

This scenario is common when developing composer packages - i.e before they can be installed from Packagist


Package installed with Composer from a repo defined in composer.json:

"repositories": [
        {
            "type": "path",
            "url": "../relativepathto/package"
        }
    ],

As this is a path type repo, by default composer creates a symlink in ./vendor/publisher/ to the package's source

Is therefore included in ./vendor/composer/installed.json:

{
            "name": "publisher/package",
            "version": "dev-master",
            "version_normalized": "dev-master",
            "dist": {
                "type": "path",
                "url": "../relativepathto/package",
                "reference": "a7acca5e62f96425339de18a781fee5a83e7b84a"
            },
           ... ...
            "type": "library",
            "extra": {
                "laravel": {
                    "providers": [
                        "publisher\\package\\provider"
                    ]
                }
            },
            "installation-source": "dist",
            "autoload": {
                "psr-4": {
                    "publisher\\package\\": "src/"
                }
            },
            ... ...
            "transport-options": {
                "relative": true
            },
            "install-path": "../publisher/package"
        },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions