2

Recently, i gave up Taglist for Tagbar. Tagbar works as expected for all languages except PHP. It lists class, methods and variables into their respective categories instead of displaying methods and variables into their respective scope.

I came to know that ctags has poor support for PHP.

Is there any way to improve ctags and Tagbar's support for PHP? I am hopping for some kind of hack or tweak, or any other way around.

2 Answers 2

5

I have just using PHP_Parser as syntax parsing backend written a tool called phpctags to generate ctags compatiable index file and an addon plugin for tagbar called tagbar-phpctags to enhance the PHP suport for tagbar.

Methods and properties even local variables assigned in functions could be listed in their own scope now as well as their access information.

Maybe these could help.

3
  • Very nice! I'll add a link to your plugin to the Tagbar wiki.
    – Jan Larres
    Jul 11, 2012 at 5:11
  • @Techlive Zheng - m getting phpctags not recognized as internal or external command, i have included it to the system path. Is there any detail guide???
    – Asur
    Sep 23, 2012 at 11:32
  • @user949293 Any luky? Both phpctags and tagbar-phpctags should be installed.
    – weynhamz
    Sep 30, 2012 at 11:20
2

Unfortunately there is no easy answer to this. The ctags PHP parser just uses regular expressions, and the result -- as you noticed -- is that support for scopes is missing.

There would be two ways to get proper scope support working: someone has to write either an actual recursive parser module for ctags, or some other program that can output tags in a ctags compatible format. That could theoretically even be written in PHP, which might make it easier -- maybe there already is some functionality available that allows access to the AST, which would then just need to be printed out in the correct format. But until someone does that I'm afraid there's no real way to properly display PHP scopes in Tagbar, since it has to rely on the information that ctags hands to it.

1

Your Answer

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

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