Skip to content
Interface to Phpactor (an intelligent code-completion and refactoring tool for PHP)
Emacs Lisp Makefile PHP
Branch: master
Clone or download
zonuexe Merge pull request #137 from br3athein/make-class-import-truly-intera…
…ctive

[IMP] Make `phpactor-import-class' actually interactive
Latest commit a12ec67 Sep 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests Merge pull request #118 from emacs-php/feature/phpactor-executable-de… Aug 12, 2019
.editorconfig Update .editorconfig Apr 30, 2018
.gitignore Add composer.json Apr 30, 2018
.travis.yml buttercup first tests with linked changes in phactor.el Mar 25, 2019
CHANGELOG.org Fix typo Sep 19, 2018
CONTRIBUTING.md
Cask buttercup first tests with linked changes in phactor.el Mar 25, 2019
Makefile Add cask install to make Jun 20, 2019
README.org Merge pull request #118 from emacs-php/feature/phpactor-executable-de… Aug 12, 2019
company-phpactor.el Asynchronous function call with phpactor--rpc-async Aug 20, 2019
composer.json
composer.lock composer update Apr 3, 2019
phpactor.el [IMP] Make `phpactor-import-class' actually interactive Sep 13, 2019

README.org

phpactor.el - PHP refactoring and introspection

This package is Emacs interface to Phpactor.

NOTICE: This package is in development. Since some functions are running, this is released as an alpha version.

NOTICE: Phpactor is also in development stage.

MELPA: phpactor MELPA stable: phpactor

Installation

Requirement: You need to have composer globally installed.

First step

Installation with use-package :

(use-package phpactor :ensure t)
(use-package company-phpactor :ensure t)

Installation with straight.el

(here using straight.el with use-package)

(use-package phpactor
  :straight (phpactor
             :host github
             :type git
             :repo "emacs-php/phpactor.el"
             :branch "master"
             :files ("*.el" "composer.json" "composer.lock" (:exclude "*test.el"))
             )
  )

Second step

After having installed this package, run `phpactor-install-or-update` (this will install a supported version of phpactor inside `.emacs.d/phpactor`).

NOTICE: To ensure the supported version of Phpactor is installed, you might need to run this command again after an upgrade of this package.

Alternatively, you can install Phpactor on your own and customize `phpactor-executable` but please be aware that any change in Phpactor’s rpc protocol can introduce breakages.

Configuration

completion

(use-package php-mode
  ;;
  :hook ((php-mode . (lambda () (set (make-local-variable 'company-backends)
       '(;; list of backends
         company-phpactor
         company-files
         ))))))

eldoc integration

(add-hook 'php-mode-hook
          (lambda ()
            (make-local-variable 'eldoc-documentation-function)
            (setq eldoc-documentation-function
                  'phpactor-hover)))

phpactor itself

See https://phpactor.github.io/phpactor/configuration.html

keybindings

Phpactor.el doesn’t bring any keybindings and it’s up to you to configure them as you wish.

You could for example limit yourself to only one by using transient.el like this

(define-transient-command php-transient-menu ()
  "Php"
  [["Class"
    ("cc" "Copy" phpactor-copy-class)
    ("cn" "New" phpactor-create-new-class)
    ("cr" "Move" phpactor-move-class)
    ("ci" "Inflect" phpactor-inflect-class)
    ("n"  "Namespace" phpactor-fix-namespace)]
   ["Properties"
    ("a"  "Accessor" phpactor-generate-accessors)
    ("pc" "Constructor" phpactor-complete-constructor)
    ("pm" "Add missing props" phpactor-complete-properties)
    ("r" "Rename var locally" phpactor-rename-variable-local)
    ("R" "Rename var in file" phpactor-rename-variable-file)]
  ["Extract"
    ("ec" "constant" phpactor-extract-constant)
    ("ee" "expression" phpactor-extract-expression)
    ("em"  "method" phpactor-extract-method)]
  ["Methods"
    ("i" "Implement Contracts" phpactor-implement-contracts)
    ("m"  "Generate method" phpactor-generate-method)]
  ["Navigate"
    ("x" "List refs" phpactor-list-references)
    ("X" "Replace refs" phpactor-replace-references)
    ("."  "Goto def" phpactor-goto-definition)]
  ["Phpactor"
    ("s" "Status" phpactor-status)
    ("u" "Install" phpactor-install-or-update)]])

Troubleshooting

You can run “phpactor-status“ while visiting a project file.

If needed, configure the way the project root is detected via .dir-locals.el

Phpactor Output” buffer might also contain useful informations.

About Phpactor

We will assume your emacs configuration is stored under “~/.emacs.d/”

Where is phpactor installed

After running `phpactor-install-or-update`, phpactor should be installed under “~/.emacs.d/phpactor/”. And the phpactor executable should be “~/.emacs.d/phpactor/vendor/bin/phpactor”

Contribute to phpactor

Phpactor’s packages are cloned (using git) under “~/.emacs.d/phpactor/vendor/phpactor”. If you make a modification to phpactor you’d like to contribute, you can just of git straight away to open a pull request therefrom.

You can’t perform that action at this time.