2

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 '15 at 3:55
  • Note though that PHP Mode is currently unmaintained. You'll probably not see this bug fixed unless you fix it yourself. – lunaryorn May 26 '15 at 5:18
  • @lunaryorn Do you have any other suggestion for coding in PHP? – Oskar Persson May 26 '15 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… – lunaryorn May 26 '15 at 6:48
  • a php-mode fork is under current development, and is available (as php-mode) from melpa: github.com/ejmr/php-mode – Michael Paulukonis May 29 '15 at 15:00
2

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 – Oskar Persson May 29 '15 at 15:40
  • I'll try when I get home but I think flycheck is major mode independent. – Jesse May 29 '15 at 20:44
  • I edited the answer. Please try if it works – Jesse May 29 '15 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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