I have the latest Emacs and php-mode setup and this code does not get indented correctly

$app->group('/route', function () use ($app) {
    echo 'hello';

Instead it looks like this

$app->group('/route', function () use ($app) {
        echo 'hello';

Note both the last line and that it indents the echo with 8 spaces instead of 4.

I've tried M-x php-enable-psr2-coding-style but it still doesn't work.

  • Probably open a bug against php-mode rather than asking a question here?
    – PythonNut
    May 26, 2015 at 3:55
  • Note though that PHP Mode is currently unmaintained. You'll probably not see this bug fixed unless you fix it yourself.
    – user227
    May 26, 2015 at 5:18
  • @lunaryorn Do you have any other suggestion for coding in PHP? May 26, 2015 at 6:33
  • @Oskar No, I do not write PHP on a regular basis, and if I had to I'd buy PHPStorm. But I doubt that there's any other PHP Mode for Emacs…
    – user227
    May 26, 2015 at 6:48
  • a php-mode fork is under current development, and is available (as php-mode) from melpa: github.com/ejmr/php-mode May 29, 2015 at 15:00

1 Answer 1


Instead of php-mode you can try web-mode. It supports php very well and seemed to indent correctly your example.

Edit: In order to make flycheck parses php, add the following to your web-mode-hook:

(flycheck-mode 1)
(flycheck-add-mode 'php 'web-mode)
  • Only problem with this is that I can't use Flycheck in web-mode May 29, 2015 at 15:40
  • I'll try when I get home but I think flycheck is major mode independent.
    – Jesse
    May 29, 2015 at 20:44
  • I edited the answer. Please try if it works
    – Jesse
    May 29, 2015 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.