Skip to content

putyourlightson/craft-autocomplete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stable Version Total Downloads

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

demo

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.

screenshot

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.

screenshot-mixins


Created by PutYourLightsOn.

About

Provides autocompletion for Craft CMS and plugins in Twig templates.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages