CTags management in PHP

We have already talked about ctags before in the entry Text Editors and CTags

However if you are a PHP developer then you may have noticed that the tag command ctags -R . becomes awfully slow for anything but trivial projects.

This is usually as a result of the ctags file becoming too large from indexing entries from composer.

To take care of this problem, simply create two indexes, one for your src folder or whichever folder you use as sources folder and one for the vendor folder which contains all external libraries code.

You can achieve this separation by doing the following from the root of your php application

  1. rm tags \\If you already have a tags file
  2. ctags -R --PHP-kinds=+cf src \\Creates the tags file for your sources folder
  3. ctags -R --PHP-kinds=+cf -f tags.vendors vendor \\Creates tags file for your vendor directory

Now when you run ctags -R . only the files in your src directory will get reindexed.

This also implies that you manually need to reindex the vendor tags by running the command shown in 3 above. This only needs to happen when you update your composer file. Instructions on automating this part are in the Text Editors and CTags article.

If you enjoyed this, remember to signup for the weekly newsletter from the form on the right.

Thank you for reading.


Published by


Software Project Manager