emacs-php / php-mode

A powerful and flexible Emacs major mode for editing PHP scripts
GNU General Public License v3.0
583 stars 118 forks source link

Experimental feature: PHP-IDE #709

Closed zonuexe closed 1 year ago

zonuexe commented 1 year ago

This feature is under development and experimental. All of these functions, modes and terms are subject to change without notice.

Motivations

There are some IDE-like features / packages for PHP development. PHP-IDE bridges projects and their IDE-like features.

IDE Features

We don't recommend features, but bundle some feature bridges. They are sorted alphabetically except none.

Configuration

Put follows code into your .emacs (~/.emacs.d/init.el) file:

(defun init-php-mode-setup ()
  (add-hook 'hack-local-variables-hook #'php-ide-mode t t))

(defun init-php-ide-mode-setup (feature activate)
  (pcase feature
    (`lsp-bridge
     (if activate
         (progn (yas-minor-mode +1)
                (corfu-mode -1))
       (yas-minor-mode -1)
       (corfu-mode +1)))))

(with-eval-after-load 'php-ide
  (custom-set-variables
   '(php-ide-features . 'eglot) ;; and/or 'none, 'phpactor, 'lsp-mode
   '(php-ide-eglot-executable "psalm-language-server") ;; or "intelephense", '("php" "vendor/bin/path/to/server")
   ;; If you want to hide php-ide-mode from the mode line, set an empty string
   '(php-ide-mode-lighter ""))

  (add-hook 'php-mode-hook #'init-php-mode-setup)
  (add-hook 'php-ide-mode-functions #'init-php-ide-mode-setup))

If you don't enable IDE support by default, set '(php-ide-feature 'none)

For per project configuration

Put follows code into .dir-locals.el in project directory:

((nil (php-project-root . git))
 (php-mode (php-ide-features . (lsp-mode))))

If you can't put .dir-locals.el in your project directory, consider the sidecar-locals package.

close https://github.com/emacs-php/php-mode/pull/656.