Answer the question
In order to leave comments, you need to log in
How to set up PHP fatal error checking in Emacs?
Hello. Moving from IDE to Emacs. I'm slowly setting it up for PHP development. I got to checking the code for errors. Found out that the best solution is flycheck. Can you please tell me how to check the code for fatal errors (undefined methods, undefined variables) using flycheck? Thanks in advance.
Answer the question
In order to leave comments, you need to log in
Flycheck relies on external tools for syntax checking and static analysis.
The solution to your problem consists of several stages.
1. Installing php-mode.
2. Install flycheck.
3. Installing external utilities for syntax checking and static analysis of PHP code.
1. Installing php-mode.
I use straight.el for this . You can use any other package manager. The settings described below will work for you almost unchanged.
(straight-use-package 'php-mode)
(defun setup-php-mode ()
"Settings for 'php-mode'"
(interactive)
(flycheck-mode 1))
(add-to-list 'auto-mode-alist '("\\.php\\'" . php-mode))
(add-hook 'php-mode-hook #'setup-php-mode)
;; FLYCHECK
(straight-use-package `flycheck)
(defun setup-flycheck-mode ()
"Settings for 'flycheck-mode'."
(interactive)
(defvar flycheck-check-syntax-automatically '(mode-enabled save))
(defvar flycheck-indication-mode 'left-margin)
(setq
flycheck-check-syntax-automatically '(mode-enabled save)
flycheck-indication-mode 'left-margin))
(add-hook 'flycheck-mode-hook #'setup-flycheck-mode)
flycheck-verify-setup
. The new buffer will display information about what external tools Flycheck relies on. If necessary, install them using your OS's package manager. Make changes to the file and see what warnings and errors Flycheck generates.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question