Skip to content

Possible to handle Laravel Facades? #209

Closed

Description

@bilogic

Love the speed of this language server!

Have a feature request to do an extra lookup when encountering a Laravel facades, let me explain

The problem

TLDR

  1. Let's say we have a method1 in a class \App\MyClass::method1()
  2. Laravel allows direct calling by writing App\Facades\MyClass::method1()
  3. My request here is when I press F12 on App\Facades\MyClass::method1(), it should link to the code of \App\MyClass::method1()

Actual steps

  1. The above explanation implies the lookup is just by namespace, but it isn't
  2. App\Facades\FacadeClass is known as the facade class
  3. App\ActualClass is known as the actual class
  4. What happens is that in the FacadeClass, there is a method called getFacadeAccessor which returns a unique reference string
  5. Developer will define which ActualClass should be instantiated based on the reference string
  6. This definition is usually found in one of the many Laravel Service Providers
  7. To an outsider, this might seem over engineered, but it has many benefits especially in areas of testing
  8. I can explain and answer any questions but the above should be sufficient for implementation consideration

Possible solution

  1. The tricky bit is about finding the ActualClass
  2. Perhaps we could annotate the FacadeClass with information about the ActualClass, perhaps with @see?
  3. This will make it much easier to lookup with minimal load on the developer (to annotate all the facade classes)
    /**
    * @see App\ActualClass
    */
    class FacadeClass {}
    
    class ActualClass {}
    

I propose this be a configurable option to avoid slowing down for non Laravel projects

Thank you!

Activity

  1. bilogic commented on Nov 3, 2025

    @bilogic
    Author

    Upon further reading and trying, I found that adding a @mixin \App\ActualClass to my FacadeClass works and allowed me to jump directly to the method. Closing this. Thank you.

  2. zobo commented on Nov 3, 2025

    @zobo
    Collaborator

    Great you managed to solve it. This is what I wanted to recommend, see if you can annotate the code so that resolving works.
    Also, for future reference, these kind of requests are best created on the main repo https://github.com/phpactor/phpactor . this is just the extension that takes care of vscode integration. Best!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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