{"id":13443170,"url":"https://github.com/xcwen/ac-php","last_synced_at":"2026-01-10T18:59:27.985Z","repository":{"id":26546905,"uuid":"30000430","full_name":"xcwen/ac-php","owner":"xcwen","description":"emacs auto-complete  \u0026 company-mode  for php","archived":false,"fork":false,"pushed_at":"2024-04-26T06:53:41.000Z","size":15315,"stargazers_count":165,"open_issues_count":5,"forks_count":35,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-28T06:57:38.092Z","etag":null,"topics":["ac-php","auto-complete","company-php","emacs","php","spacemacs"],"latest_commit_sha":null,"homepage":"","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xcwen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-29T02:48:50.000Z","updated_at":"2024-08-17T21:25:51.000Z","dependencies_parsed_at":"2022-07-13T10:20:25.692Z","dependency_job_id":"33d341bf-d275-44de-a0ed-09641e15dd78","html_url":"https://github.com/xcwen/ac-php","commit_stats":null,"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcwen%2Fac-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcwen%2Fac-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcwen%2Fac-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcwen%2Fac-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xcwen","download_url":"https://codeload.github.com/xcwen/ac-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244649678,"owners_count":20487467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ac-php","auto-complete","company-php","emacs","php","spacemacs"],"created_at":"2024-07-31T03:01:57.029Z","updated_at":"2026-01-10T18:59:27.944Z","avatar_url":"https://github.com/xcwen.png","language":"Emacs Lisp","funding_links":[],"categories":["Emacs Lisp"],"sub_categories":[],"readme":"# ac-php\n[![Build Status][:badge-travis:]][:project-travis:]\n\nA GNU Emacs auto completion source for the PHP.\n\n---\n\n## Table of Contents\n\n* [About ac-php](#about-ac-php)\n* [Provide Features](#provide-features)\n  * [PHPDoc annotations](#phpdoc-annotations)\n  * [Type hints](#type-hints)\n* [Install](#installation)\n  * [Using MELPA](#using-melpa)\n* [Usage](#usage)\n  * [Commands](#commands)\n  * [auto-complete](#auto-complete)\n  * [company-mode](#company-mode)\n  * [Spacemacs](#spacemacs)\n  * [Working with tags](#working-with-tags)\n  * [Using configuration file](#using-configuration-file)\n  * [Rebuilding tags](#rebuilding-tags)\n* [FAQ](#faq)\n* [License](#license)\n\n## About ac-php\n\nThis repository contains:\n\n- **ac-php-core**, the core library of the ac-php package\n  [![MELPA][:badge-ac-php-core:]][:project-ac-php-core:]\n  [![MELPA Stable][:badge-ac-php-core-s:]][:project-ac-php-core-s:]\n- **ac-php**, auto completion source for PHP to use with `auto-complete`\n  [![MELPA][:badge-ac-php:]][:project-ac-php:]\n  [![MELPA Stable][:badge-ac-php-s:]][:project-ac-php-s:]\n- **company-php**, a `company-mode` back-end for PHP\n  [![MELPA][:badge-company-php:]][:project-company-php:]\n  [![MELPA Stable][:badge-company-php-s:]][:project-company-php-s:]\n- **helm-ac-php-apropros**, an apropos functionality using the ac-php index and `helm` as interface\n\n## Provide Features\n\nThe PHP code completion and the jump to definition/declaration/inclusion-file provided by [phpctags][:phpctags:].\n\n- Support of [`auto-complete`][:gh-ac:], [`company-mode`][:gh-company:]\n\n- use [phpstorm stubs][:phpstorm-stubs:] for completion.\n\n- Auto Completion for user defined classes\n\n- Support of annotations and type hints\n- Currently ships with [Spacemacs][:gh-spacemacs:]\n\nFor more see [screenshots][:screenshots:] page.\n\n#### PHPDoc annotations\n\nac-php supports PHPDoc annotations. Thus auto completion should work for:\n\n\n**Property annotations**\n\n```php\n/**\n * @var \\Acme\\Services\\HelloService\n */\npublic $hello;\n```\n\n**Invisible (magic) members annotations**\n\n```php\n/**\n * @property \\Acme\\Services\\HelloService $hello\n * @property-read \\Acme\\Services\\HelloService $hello_r\n * @property-write \\Acme\\Services\\HelloService $hello_w\n */\nclass Test\n{\n    // ...\n}\n```\n\n**Return type annotations**\n\n```php\n/**\n * @return \\Acme\\Services\\HelloService\n */\npublic function get_v1()\n\n```\n\n**Invisible (magic) methods annotations**\n\n```php\n/**\n * @method \\Acme\\Services\\HelloService hello()\n */\nclass Test\n{\n    // ...\n}\n```\n\n**Variable annotations**\n\n```php\n/** @var \\Acme\\Services\\HelloService $hello */\n$hello = hello();\n```\n\n**Note:** if a function or a class member has no defined return value then you need to define it using annotation.\n\n#### Type hints\n\nIn addition, ac-php supports return / parameter type hints.\nThus you'll get additional auto completion support for the following cases:\n\n**Parameter type hints**\n\n``` php\nuse Acme\\Services\\HelloService;\n\npublic function hello(HelloService $service)\n{\n    // ...\n}\n```\n\n**PHP 7 return type hints**\n\n```php\npublic function hello(): \\Acme\\Services\\HelloService\n{\n    // ...\n}\n```\n**PHP 8 type**\n\n```php\nclass Test\n{\n    public  \\Acme\\Services\\HelloService $hello;\n}\n\n```\n\n\n## Installation\n\nKnown to work with GNU Emacs 24.4 and later. ac-php may work with older versions of GNU Emacs, or with other flavors of GNU Emacs (e.g. XEmacs) but this is not guaranteed. Bug reports for problems related to using ac-php with older versions of Emacs will most like not be addressed.\n\nPrerequisite packages are:\n\n- **Common**\n  - GNU Emacs \u003e= 24.4\n  - PHP CLI\n  - [php-mode][:gh-php-mode:]\n- **`ac-php-core.el`**\n  - [s][:melpa-s:]\n  - [f][:melpa-f:]\n  - [popup][:melpa-popup:]\n  - [dash][:elpa-dash:]\n  - [xcscope][:melpa-xcscope:]\n  - [scope][:sf-cscope:] (optional)\n- **`ac-php.el`**\n  - [auto-complete][:gh-ac:]\n  - [yasnippet][:gh-yasnippet:]\n- **`helm-ac-php-apropros.el`**\n  - [helm][:gh-helm:]\n- **`company-php.el`**\n  - [company][:gh-company:]\n\n### Using MELPA\n\nThe best way of installing ac-php, at least for GNU Emacs 24, is to use the packaging system. Add MELPA or MELPA Stable to the list of repositories to access this mode. For those who want only formal, tagged releases use MELPA Stable:\n\n``` elisp\n(require 'package)\n(add-to-list 'package-archives\n             '(\"melpa-stable\" . \"https://stable.melpa.org/packages/\") t)\n(package-initialize)\n```\nFor those who want rolling releases as they happen use MELPA:\n\n``` elisp\n(require 'package)\n(add-to-list 'package-archives\n             '(\"melpa\" . \"https://melpa.org/packages/\") t)\n(package-initialize)\n```\n\nand then use `M-x package-refresh-contents` and `M-x package-list-packages` to get to\nthe package listing and install `ac-php` from there. MELPA tracks this Git repository\nand updates relatively soon after each commit or formal release.  For more detail on\nsetting up see [MELPA Getting Started][:melpa-gs:].\n\nYou can install `ac-php` manually by adding following to your init file:\n\n``` elisp\n(unless (package-installed-p 'ac-php)\n    (package-refresh-contents)\n    (package-install 'ac-php))\n```\n\n## Usage\n\n### Commands\n\n| Command                       | Description                                                |\n| ----------------------------- | ---------------------------------------------------------- |\n| `ac-php-remake-tags`          | Run this command to update tags if source has been changed |\n| `ac-php-remake-tags-all`      | Run this command if you find an error                      |\n| `ac-php-find-symbol-at-point` | Jump to definition                                         |\n| `ac-php-location-stack-back`  | Return back                                                |\n| `ac-php-show-tip`             | Show definition at point                                   |\n| `ac-php-toggle-debug`         | Toggle debug mode                                          |\n| `helm-ac-php-apropos`         | Search through all the definitions of a project with helm  |\n\n### auto-complete\n\n1. Add hook as follows:\n\n``` elisp\n(require 'php-mode)\n\n(add-hook 'php-mode-hook\n          '(lambda ()\n             ;; Enable auto-complete-mode\n             (auto-complete-mode t)\n\n             (require 'ac-php)\n             (setq ac-sources '(ac-source-php))\n\n             ;; As an example (optional)\n             (yas-global-mode 1)\n\n             ;; Enable ElDoc support (optional)\n             (ac-php-core-eldoc-setup)\n\n             ;; Jump to definition (optional)\n             (define-key php-mode-map (kbd \"M-]\")\n               'ac-php-find-symbol-at-point)\n\n             ;; Return back (optional)\n             (define-key php-mode-map (kbd \"M-[\")\n               'ac-php-location-stack-back)))\n```\n\n2. Create the [configuration file](#using-configuration-file) `.ac-php-conf.json` in the project root:\n\n```sh\n$ cd /project/to/poject/root\n$ touch .ac-php-conf.json\n```\n\nYou can add the standard php library with [phpstorm stubs][:phpstorm-stubs:].\n```\ncomposer require  jetbrains/phpstorm-stubs\n```\n\n\nAnd use `M-x company-complete` to complete.\n\n### company-mode\n\n1. Add hook as follows:\n\n``` elisp\n(require 'php-mode)\n\n(add-hook 'php-mode-hook\n          '(lambda ()\n             ;; Enable company-mode\n             (company-mode t)\n             (require 'company-php)\n\n             ;; Enable ElDoc support (optional)\n             (ac-php-core-eldoc-setup)\n\n             (set (make-local-variable 'company-backends)\n                  '((company-ac-php-backend company-dabbrev-code)\n                    company-capf company-files))\n\n             ;; Jump to definition (optional)\n             (define-key php-mode-map (kbd \"M-]\")\n               'ac-php-find-symbol-at-point)\n\n             ;; Return back (optional)\n             (define-key php-mode-map (kbd \"M-[\")\n               'ac-php-location-stack-back)))\n```\n\n2. Create the [configuration file](#using-configuration-file) `.ac-php-conf.json` in the project root:\n\n```sh\n$ cd /project/to/poject/root\n$ touch .ac-php-conf.json\n```\n\nAnd use `M-x company-complete` to complete.\n\n### Spacemacs\n\nTo use ac-php with Spacemacs please refer to:\nhttps://github.com/syl20bnr/spacemacs/tree/develop/layers/%2Blang/php\n\n### Working with tags\n\nac-php uses its own tags format. By default all tags located at `~/.cache/ac-php/tags-\u003cproject-directory\u003e`.\nFor example, if the real path of the project is `/home/jim/ac-php/phptest`, then tags will be placed at\n`~/.cache/ac-php/tags-home-jim-ac-php-phptest/`.\n\nAnd you can redefine the base path (`~/.cache/ac-php`) using `ac-php-tags-path` variable.\n\n\n### Using configuration file\n\nBecause of the way that the ac-php package works, there are a couple of simple\ninitialization tasks which must occur to get the completion working as it should.\nOn any new project make sure to perform the following initialization tasks:\n\n1. Run the following\n\n   ```sh\n   cd /root/of/project\n   touch .ac-php-conf.json\n   ```\n\n2. Inside of Emacs run:\n   `M-x` `ac-php-remake-tags`\n\nThe `.ac-php-conf.json` file is required to enable auto-completion. When you run `ac-php-remake-tags` and your `.ac-php-conf.json` file is empty the default configuration will be used and inserted in the file.\n\nIf your project contains the following files at the root folder:\n\n1. `.projectile`\n2. `vendor/autoload.php`\n\nthe necessary configuration file (`.ac-php-conf.json`) will be created automatically if it does not exist. Its contents will be similar to:\n\n```json\n{\n  \"filter\": {\n    \"php-file-ext-list\": [\n      \"php\"\n    ],\n    \"php-path-list\": [\n      \".\"\n    ],\n    \"ignore-ruleset\": [\n      \"# like .gitignore file \",\n      \"/vendor/**/[tT]ests/**/*.php\"\n    ]\n\n  }\n}\n```\n\n- `php-file-ext-list`: file extern name list\n- `php-path-list`:  base path for *recursive* file search to collect tags\n- `ignore-ruleset`:  exclude files config, like '.gitignore'  in git as lines \n\n\n\n### Rebuilding tags\n\nIf source has been changed, you may need run `ac-php-remake-tags` to remake tags.\n\nac-php internally uses [phpctags][:phpctags:], so its operability depends on the correct\nsyntax you use in the project. If something goes wrong with one of your files, you can find\nall errors in the `*Messages*` buffer. For example:\n\n```\nphpctags[/home/jim/phptest/testa.php] ERROR:PHPParser: Unexpected token '}' on line 11 -\n```\n\nIn this case you'll need to fix an error in `testa.php` and re run `ac-php-remake-tags`.\n\n\n**Note:** You shouldn't download phpctags, ac-php already ships with its own modified version.\n\n\nIf you see something like this:\n\n```\nac-php: Unable to resolve project root\n```\n\nThis means you have to create the `.ac-php-conf.json` file in the project root:\n\n``` sh\n$ touch /path/to/the/project/.ac-php-conf.json\n```\n\n## FAQ\n\n- **Q:** Something went wrong. It seems I followed all the instructions, but auto completion stopped working\n- **A:** Run `M-x ac-php-remake-tags-all`\n\n---\n\n- **Q:** How I can create a reproducible test to create an issue?\n- **A:** Please use [this issue][:issue-example:] as an example\n\n## License\n\nac-php is open source software licensed under the GNU General Public Licence version 3 .\n\n[:badge-ac-php:]: http://melpa.org/packages/ac-php-badge.svg\n[:badge-ac-php-s:]: http://stable.melpa.org/packages/ac-php-badge.svg\n[:badge-ac-php-core:]: http://melpa.org/packages/ac-php-core-badge.svg\n[:badge-ac-php-core-s:]: http://stable.melpa.org/packages/ac-php-core-badge.svg\n[:badge-company-php:]: https://melpa.org/packages/company-php-badge.svg\n[:badge-company-php-s:]: http://stable.melpa.org/packages/company-php-badge.svg\n[:badge-travis:]: https://travis-ci.com/xcwen/ac-php.svg\n[:project-travis:]:https://travis-ci.com/xcwen/ac-php\n[:project-ac-php:]: http://melpa.org/#/ac-php\n[:project-ac-php-s:]: http://stable.melpa.org/#/ac-php\n[:project-ac-php-core:]: http://melpa.org/#/ac-php-core\n[:project-ac-php-core-s:]: http://stable.melpa.org/#/ac-php-core\n[:project-company-php:]: https://melpa.org/#/company-php\n[:project-company-php-s:]: http://stable.melpa.org/#/company-php\n[:gh-ac:]: https://github.com/auto-complete/auto-complete\n[:gh-company:]: https://github.com/company-mode/company-mode\n[:gh-spacemacs:]: https://github.com/syl20bnr/spacemacs\n[:gh-helm:]: https://github.com/emacs-helm/helm\n[:gh-php-mode:]: https://github.com/emacs-php/php-mode\n[:gh-yasnippet:]: https://github.com/joaotavora/yasnippet\n[:melpa-gs:]: https://melpa.org/#/getting-started\n[:phpstorm-stubs:]: https://github.com/JetBrains/phpstorm-stubs\n[:issue-example:]: https://github.com/xcwen/ac-php/issues/51\n[:phpctags:]: https://github.com/xcwen/phpctags\n[:screenshots:]: https://github.com/xcwen/ac-php/tree/master/screenshots\n[:elpa-dash:]: https://elpa.gnu.org/packages/dash.html\n[:melpa-f:]: https://melpa.org/#/f\n[:melpa-s:]: https://melpa.org/#/s\n[:melpa-popup:]: https://melpa.org/#/popup\n[:melpa-xcscope:]: https://melpa.org/#/xcscope\n[:sf-cscope:]: http://cscope.sourceforge.net\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcwen%2Fac-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxcwen%2Fac-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcwen%2Fac-php/lists"}