-
Notifications
You must be signed in to change notification settings - Fork 25
End User Guide
Contents
To install Crane, you have several options. You can either install it via the built-in extension installer, or via the .vsix
download file from the releases page.
Via the Built-in Extension Installer
- Open VS Code
- Press F1 to open the command palette
- Type
ext install
and selectInstall Extension
from the list that appears - Type
crane
and select Crane from the list - Restart VS Code when prompted
Via the .vsix
Download File
- Go to the releases page
- Download the
crane-[version].vsix
file from the relevant release - Open VS Code
- Select
File -> Open
and choose the downloaded.vsix
file - Restart VS Code when prompted
Crane will initialise automatically when you open a PHP file and begin processing each PHP file in the workspace folder to build an Abstract Syntax Tree (AST) for generating suggestions and code analysis.
Simply start typing in a PHP file to have variables, functions, classes and more suggested. While VS Code has it's "24/7 code-completion", Crane specific code-completion is triggered when you type one of the following characters: $
.
>
:
If you have the cache setting enabled, then Crane will cache the generated AST to a local file for fast access when you close and re-open the project again. If you modify any of the files in the workspace outside of VS Code, you will need to regenerate this cache when you open the project again. To do this, press F1 and type crane rebuild cache
. This will then re-index the workspace and rebuild the cache file.
Crane has some commands that you can run manually to perform certain actions:
Report PHP Intellisense Bug
This command allows you to navigate directly to the GitHub issues page to report a bug with Crane.
Reindex PHP files in the workspace
This command allows you to reindex all PHP files in the workspace. This is useful to rebuild the cache if something isn't working correctly.
Delete all PHP file caches
This command deletes all of the existing workspace caches. Over time these cache files can build up and consume disk space, so running this command infrequently is probably a good idea.
Download PHP library stubs
This command allows you to download and install the PHP library stubs for the built-in classes and selected PHP extensions.
Crane currently has a limited feature-set and can only provide semi-basic code-completion for variables, classes, functions and class level properties and methods accessed via $this->
, self::
, or via an instantiated variable (eg. $foo = new Bar(); $foo->
).
Crane cannot currently provide suggestions for nested instantiated properties (eg. $this->prop->
).
It also does not currently parse phpDoc comments; these will just be ignored.
Crane has a number of settings that can be configured in your global user settings, or in the workspace specific settings.
crane.showStatusBarBugReportLink
This setting allows you to show or hide the link in the status bar footer prompting you to file a bug report if you find an issue with Crane.
crane.saveCache
This setting allows you to enable or disable the cache functionality that stores the generated AST to a local file for fast access when reloading a project.
crane.debugMode
This setting allows you to enable debug mode which generates log information about files being parsed and errors that might be generated. In future this may be expanded to show additional code analysis or suggestion debug information.
crane.phpstubsZipFile
This setting allows you to define where the PHP library stubs will be downloaded from.
These files, available on the crane-php-stubs repository, contain "stub" classes/functions for built-in or selected 3rd party PHP extensions so that rich suggestions can be generated for them.
You can add your own stubs by creating a new folder next to the existing directory and putting your stubs inside.
TODO: Expand this
If you examine an existing stub (eg. PDO.php) then you will see the format required - all Crane needs is the class/function outline plus as much documentation as possible. No actual code inside each function is needed.