Most IDEs have some form of code completion as part of the program. To enable auto-completion for Phalcon's namespaces, we will need to help the IDE recognize those namespaces. We will also see how to enable Volt syntax highlighting and Phalcon API auto-completion for major IDEs.
To get started, we should have Git installed. To enable auto-completion in your IDE, you need to get the Phalcon stubs. For these purposes, clone the Phalcon Developer Tools
repository:
git clone [email protected]:phalcon/phalcon-devtools.git
The following are the steps needed to complete this recipe.
Using the Project Tool window in PhpStorm, select External Libraries, right-click on the section, and select Configure PHP Include Paths... from the drop-down menu.
Then, using the External Libraries dialog box, click the + button. Next, select the Specify Other... option in the drop-down menu and specify the location of the Phalcon stubs. The stubs are located in the
phalcon-devtools
repository you just cloned under the/ide
subfolder. You should specify the pathphalcon-devtools/ide/stubs/Phalcon
and click on Apply.
In NetBeans, you need to open the Projects window (Ctrl + F1) and select Include Path. Right-click on the section and select Properties from the drop-down menu.
Then, open the Project Properties window and click on the Add Folder... button. Next, specify the location of the Phalcon stubs. The stubs are located in the
phalcon-devtools
repository you just cloned under the/ide
subfolder. You should specify the pathphalcon-devtools/ide/stubs/Phalcon
and click on the OK button.
In the opened window, select Miscellaneous | Files.
In the File Associations group box, click on the button New… next to the File Extensions option, enter the extension
volt,
and click on OK.Select TWIG (text/x-twig) in the Associated File Type (MIME) drop-down menu.
If you have Sublime Package Control, you know what to do. If not, well, it's a package manager for Sublime Text, and it's awesome!
After installing Sublime Package Control and restarting the editor:
For manual installation, clone the Volt
syntax highlight for the Sublime Text 2/Textmate
repository:
[email protected]:phalcon/volt-sublime-textmate.git
Depending on your OS, copy the volt-sublime-textmate/Volt
directory to any of the following locations:
Sublime Text 2:
Mac OS X:
~/Library/Application Support/Sublime Text 2/Packages
Linux:
~/.Sublime Text 2/Packages
Windows:
%APPDATA%/Sublime Text 2/Packages/
Sublime Text 3:
Mac OS X:
~/Library/Application Support/Sublime Text 3/Packages
Linux:
~/.Sublime Text 3/Packages
Windows:
%APPDATA%/Sublime Text 3/Packages/
TextMate:
/Library/Application Support/TextMate/Bundles
Some IDEs need help understanding the framework syntax. To get the IDE to understand, we download a list of all the Phalcon stubs. Then, when we add it to the include
path, NetBeans (or PhpStorm) will automatically check the file and show us the autocomplete options. To enable the Volt
or Zephir
syntax highlight, we have to configure our IDE or text editor accordingly.