putyourlightson / craft-autocomplete
Provides autocompletion for Craft and plugins in Twig templates.
Installs: 1 512
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- craftcms/cms: ^3.0.0
README
Autocomplete for Craft CMS [DEPRECATED]
⚠️ This package has been replaced by the superior Craft Autocomplete as a collaboration between PutYourLightsOn and nystudio107.
Provides autocompletion for Craft CMS and plugins in Twig templates.
Currently works with PhpStorm only, as VSCode does not support intellisense for Twig extensions.
Adapted from FauxTwigExtension.php
by nystudio107 as documented in the article:
https://nystudio107.com/blog/auto-complete-craft-cms-3-apis-in-twig-with-phpstorm
Usage
Install the package using composer.
composer require putyourlightson/craft-autocomplete
Ensure that the Symfony plugin is installed and enabled in PhpStorm:
https://plugins.jetbrains.com/plugin/7219-symfony-plugin
Once your IDE indexes the files, autocompletion for Craft and supported plugins will immediately become available in your Twig templates.
Adding Custom Variables
You can add autocompletion for your own custom modules/plugins by creating a file called AutocompleteVariable.php
and placing it inside any folder that PhpStorm will index (for example in the /config
directory).
<?php use craft\web\twig\variables\CraftVariable; use my\plugin\variables\MyVariable; /** * Adds variables to the global Craft Variable. * * @mixin MyVariable */ class AutocompleteVariable extends CraftVariable { }
Contributing
You can contribute autocompletion for third-party plugins that are available in the plugin store. To do so, copy the src/putyourlightson
folder and rename it to your GitHub username. Modify the classes accordingly and add a @mixin
for your variable to the main AutocompleteVariable
class.
Ensure you follow the structure already in place, test that autocompletion works and submit a pull request.
Created by PutYourLightsOn.