Skip to content

Support aliases for wp shell #86

Closed as not planned
Closed as not planned

Description

@schlessera

It would be hugely useful to allow for the wp-cli.yml files to define "aliases" that work inside of the wp shell REPL.

These could be defined globally or per site, and would reduce the amount of typing necessary for heavy debugging/testing sessions. So, something like $obj = new \Vendor\Package\Module\AwesomeClass(); could be simplified by providing an alias like \Vendor\Package\Module\AwesomeClass => MyAwesomeClass, so that you can simply type: $obj = new MyAwesomeClass();.

The aliases could even support entire code snippets, for setup code you often need.

Activity

  1. danielbachhuber commented on Dec 12, 2017

    @danielbachhuber
    Member

    It would be hugely useful to allow for the wp-cli.yml files to define "aliases" that work inside of the wp shell REPL.

    Can you share an example of how this might be formatted?

  2. schlessera commented on Dec 14, 2017

    @schlessera
    MemberAuthor

    It would probably look something like this:

    shell:
        alias:
            - MyAwesomeClass: \Vendor\Package\Module\AwesomeClass
    
  3. schlessera commented on Dec 14, 2017

    @schlessera
    MemberAuthor

    It should probably be smart enough to detect whether it is dealing with a class, a method/function or a variable, and produce the aliases accordingly.

    It could throw warnings when aliases are ambiguous, like when it finds both a class as well as a variable that would match.

  4. transferred this issue fromwp-cli/ideason Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions