{"id":13648051,"url":"https://github.com/felixfbecker/php-language-server","last_synced_at":"2025-05-14T17:02:54.272Z","repository":{"id":10667583,"uuid":"65535756","full_name":"felixfbecker/php-language-server","owner":"felixfbecker","description":"PHP Implementation of the VS Code Language Server Protocol 🆚↔🖥","archived":false,"fork":false,"pushed_at":"2023-05-15T12:46:10.000Z","size":2014,"stargazers_count":1170,"open_issues_count":264,"forks_count":185,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-05-13T13:59:08.026Z","etag":null,"topics":["autocomplete","code-analysis","ide","intelligence","intellisense","language-server","language-server-protocol","php","static-analysis","symbols"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/felixfbecker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-08-12T08:11:14.000Z","updated_at":"2025-05-11T19:52:00.000Z","dependencies_parsed_at":"2024-01-07T05:12:14.048Z","dependency_job_id":"63dc7a72-2ed7-4ca9-82d5-4bf9c9a93dec","html_url":"https://github.com/felixfbecker/php-language-server","commit_stats":{"total_commits":312,"total_committers":37,"mean_commits":8.432432432432432,"dds":0.3076923076923077,"last_synced_commit":"9dc16565922ae1fcf18a69b15b3cd15152ea21e6"},"previous_names":[],"tags_count":65,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixfbecker%2Fphp-language-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixfbecker%2Fphp-language-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixfbecker%2Fphp-language-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixfbecker%2Fphp-language-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felixfbecker","download_url":"https://codeload.github.com/felixfbecker/php-language-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253958076,"owners_count":21990548,"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":["autocomplete","code-analysis","ide","intelligence","intellisense","language-server","language-server-protocol","php","static-analysis","symbols"],"created_at":"2024-08-02T01:03:55.898Z","updated_at":"2025-05-14T17:02:54.221Z","avatar_url":"https://github.com/felixfbecker.png","language":"PHP","readme":"# PHP Language Server\n\n[![Version](https://img.shields.io/packagist/v/felixfbecker/language-server.svg)](https://packagist.org/packages/felixfbecker/language-server)\n[![Linux Build Status](https://travis-ci.org/felixfbecker/php-language-server.svg?branch=master)](https://travis-ci.org/felixfbecker/php-language-server)\n[![Windows Build status](https://ci.appveyor.com/api/projects/status/2sp5ll052wdjqmdm/branch/master?svg=true)](https://ci.appveyor.com/project/felixfbecker/php-language-server/branch/master)\n[![Coverage](https://codecov.io/gh/felixfbecker/php-language-server/branch/master/graph/badge.svg)](https://codecov.io/gh/felixfbecker/php-language-server)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.0-8892BF.svg)](https://php.net/)\n[![License](https://img.shields.io/packagist/l/felixfbecker/language-server.svg)](https://github.com/felixfbecker/php-language-server/blob/master/LICENSE.txt)\n[![Gitter](https://badges.gitter.im/felixfbecker/php-language-server.svg)](https://gitter.im/felixfbecker/php-language-server?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\nA pure PHP implementation of the open [Language Server Protocol](https://github.com/Microsoft/language-server-protocol).\nProvides static code analysis for PHP for any IDE.\n\nUses the great [Tolerant PHP Parser](https://github.com/Microsoft/tolerant-php-parser),\n[phpDocumentor's DocBlock reflection](https://github.com/phpDocumentor/ReflectionDocBlock)\nand an [event loop](http://sabre.io/event/loop/) for concurrency.\n\n**Table of Contents**\n  - [Features](#features)\n  - [Performance](#performance)\n  - [Versioning](#versioning)\n  - [Installation](#installation)\n  - [Running](#running)\n  - [Used by](#used-by)\n  - [Contributing](#contributing)\n\n\n## Features\n\n### [Completion](https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#textDocument_completion)\n![Completion search demo](images/completion.gif)\n\n### [Signature Help](https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#textDocument_signatureHelp)\n![Signature help demo](images/signatureHelp.gif)\n\n### [Go To Definition](https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#goto-definition-request)\n![Go To Definition demo](images/definition.gif)\n\n### [Find References](https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#find-references-request)\n![Find References demo](images/references.png)\n\n### [Hover](https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#hover-request)\n![Hover class demo](images/hoverClass.png)\n\n![Hover parameter demo](images/hoverParam.png)\n\nA hover request returns a declaration line (marked with language `php`) and the summary of the docblock.\nFor Parameters, it will return the `@param` tag.\n\n### [Document Symbols](https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#document-symbols-request)\n![Document Symbols demo](images/documentSymbol.gif)\n\n### [Workspace Symbols](https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#workspace-symbols-request)\n![Workspace Symbols demo](images/workspaceSymbol.gif)\n\nThe query is matched case-insensitively against the fully qualified name of the symbol.  \nNon-Standard: An empty query will return _all_ symbols found in the workspace.\n\n### Error reporting through [Publish Diagnostics](https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#publishdiagnostics-notification)\n![Error reporting demo](images/publishDiagnostics.png)\n\nPHP parse errors are reported as errors, parse errors of docblocks are reported as warnings.\nErrors/Warnings from the `vendor` directory are ignored.\n\n### Stubs for PHP built-ins\n\nCompletion, type resolval etc. will use the standard PHP library and common extensions.\n\n### What is considered a definition?\n\nGlobally searchable definitions are:\n - classes\n - interfaces\n - traits\n - properties\n - methods\n - class constants\n - constants with `const` keyword\n\nDefinitions resolved just-in-time when needed:\n - variable assignments\n - parameters\n - closure `use` statements\n\nNot supported yet:\n - constants with `define()`\n\nNamespaces are not considerd a declaration by design because they only make up a part of the fully qualified name\nand don't map to one unique declaration.\n\n### What is considered a reference?\n\nDefinitions/references/hover currently work for\n - class instantiations\n - static method calls\n - class constant access\n - static property access\n - parameter type hints\n - return type hints\n - method calls, if the variable was assigned to a new object in the same scope\n - property access, if the variable was assigned to a new object in the same scope\n - variables\n - parameters\n - imported closure variables (`use`)\n - `use` statements for classes, constants and functions\n - class-like after `implements`/`extends`\n - function calls\n - constant access\n - `instanceof` checks\n - Reassigned variables\n - Nested access/calls on return values, properties, array access\n\n### Protocol Extensions\n\nThis language server implements the [files protocol extension](https://github.com/sourcegraph/language-server-protocol/blob/master/extension-files.md).\nIf the client expresses support through `ClientCapabilities.xfilesProvider` and `ClientCapabilities.xcontentProvider`,\nthe server will request files in the workspace and file contents through requests from the client and never access\nthe file system directly. This allows the server to operate in an isolated environment like a container,\non a remote workspace or any a different protocol than `file://`.\n\n## Performance\n\nUpon initialization, the server will recursively scan the project directory for PHP files, parse them and add all definitions\nand references to an in-memory index.\nThe time this takes depends on the project size.\nAt the time of writing, this project contains 78 files + 1560 files in dependencies which take 97s to parse\nand consume 76 MB on a Surface Pro 3.\nThe language server is fully operational while indexing and can respond to requests with the definitions already indexed.\nFollow-up requests will be almost instant because the index is kept in memory.\n\nHaving XDebug enabled heavily impacts performance and can even crash the server if the `max_nesting_level` setting is too low.\n\n## Versioning\n\nThis project follows [semver](http://semver.org/) for the protocol communication and command line parameters,\ne.g. a major version increase of the LSP will result in a major version increase of the PHP LS.\nNew features like request implementations will result in a new minor version.\nEverything else will be a patch release.\nAll classes are considered internal and are not subject to semver.\n\n## Installation\n\nThe recommended installation method is through [Composer](https://getcomposer.org/).\nSimply run\n\n    composer require felixfbecker/language-server\n\nand you will get the latest stable release and all dependencies.  \nRunning `composer update` will update the server to the latest non-breaking version.\n\nAfter installing the language server and its dependencies,\nyou must parse the stubs for standard PHP symbols and save the index for fast initialization.\n\n     composer run-script --working-dir=vendor/felixfbecker/language-server parse-stubs\n\n## Running\n\nStart the language server with\n\n    php vendor/felixfbecker/language-server/bin/php-language-server.php\n\n### Command line arguments\n\n#### `--tcp=host:port` (optional)\nCauses the server to use a tcp connection for communicating with the language client instead of using STDIN/STDOUT.\nThe server will try to connect to the specified address.\nStrongly recommended on Windows because of blocking STDIO.\n\nExample:\n\n    php bin/php-language-server.php --tcp=127.0.0.1:12345\n\n#### `--tcp-server=host:port` (optional)\nCauses the server to use a tcp connection for communicating with the language client instead of using STDIN/STDOUT.\nThe server will listen on the given address for a connection.\nIf PCNTL is available, will fork a child process for every connection.\nIf not, will only accept one connection and the connection cannot be reestablished once closed, spawn a new process instead.\n\nExample:\n\n    php bin/php-language-server.php --tcp-server=127.0.0.1:12345\n\n#### `--memory-limit=integer` (optional)\nSets memory limit for language server.\nEquivalent to [memory-limit](http://php.net/manual/en/ini.core.php#ini.memory-limit) php.ini directive.\nThe default is 4GB (which is way more than needed).\n\nExample:\n\n    php bin/php-language-server.php --memory-limit=256M\n\n## Used by\n - [VS Code PHP IntelliSense](https://github.com/felixfbecker/vscode-php-intellisense)\n - [Eclipse Che](https://eclipse.org/che/)\n - [Eclipse IDE (LSP4E-PHP)](https://github.com/eclipselabs/lsp4e-php)\n - NeoVim: [LanguageServer-php-neovim](https://github.com/roxma/LanguageServer-php-neovim) with [LanguageClient neovim](https://github.com/autozimu/LanguageClient-neovim)\n - Atom: [ide-php](https://github.com/atom/ide-php)\n\n## Contributing\n\nYou need at least PHP 7.0 and Composer installed.\nClone the repository and run\n\n    composer install\n\nto install dependencies.\n\nRun the tests with \n\n    composer test\n\nLint with\n\n    composer lint\n    \nThe project parses PHPStorm's PHP stubs to get support for PHP builtins. It re-parses them as needed after Composer processes, but after some code changes (such as ones involving the index or parsing) you may have to explicitly re-parse them:\n\n    composer run-script parse-stubs\n    \nTo debug with xDebug ensure that you have this set as an environment variable\n\n    PHPLS_ALLOW_XDEBUG=1\n\nThis tells the Language Server to not restart without XDebug if it detects that XDebug is enabled (XDebug has a high performance impact).\n","funding_links":[],"categories":["PHP","php","类库"],"sub_categories":["调试工具"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixfbecker%2Fphp-language-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelixfbecker%2Fphp-language-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixfbecker%2Fphp-language-server/lists"}