Slim PHP Framework PhpStorm IDE autocompletion Solution

Slim PHP Framework PhpStorm IDE autocompletion Solution

I am a big fan of PHP Slim Framework. But sometimes, I realized that when I work with large and complex libraries with Slim as dependency. It just kills my productivity, it kills my valuable time too. It’s all because of I can’t remember all the method names, properties of my dependent class or libraries. And with Pimple dependencies Slim Framework don’t have any way to bypass referencing of my third party libraries which I add through it’s container as dependency. So I decided to figure out a solution for me.

First, I just installed and configured slim framework and here is my scripts.

 

And I created a class HintsClass. Now the main trick is, I created a dummy _ide_autocomplete.php file in the project root and defined all the containers key as public property. Like this.

 

Now our goal is from inside route, our PHPStorm IDE will show the autocomplete and hinting for code completion when we will access this class with $this->hints->[ctrl+space to see autocompletion]. And in our _ide_autocomplete.php file we wrote the following codes. FYI, this _ide_autocomplete.php will never execute. It just used for giving IDE as a referential hinting for all the properties .

 

You will see in this Dummy class file according to our slim containers[‘hints’], I just mentioned the same return reference here. And see my main index.php, in every route I just gave IDE hints about the $this context with

And after that from route context IDE will show the autocompletion of our dependencies like $this->hints[ctrl+space to see suggestions].

You can see my whole scripts are in GitHub https://github.com/shahariaazam/slim-phpstorm-autocomplete. And see this work in YouTube, https://www.youtube.com/watch?v=jyEvApLRofw .Please let me know if any issue found, write me in comments. Thank you.

PHPStorm Keyboard Shortcuts – For faster web PHP Coding

If you are a PHP coder just leave Dreamweaver. If you are novice website designer Dreamweaver is perfect. Now I can feel that how much bad the Dreamweaver is as an IDE! I prefer PhpStorm as my PHP IDE. Really PHPStorm is a great PHP editor for faster PHP application development. Since 3 years I used Adobe Dreamweaver but now I can be sure that Dreamweaver is such a novice playground. So if you want to be a PHP coder you should switch your IDE and you can consider PHPStorm. It’s really great to have a great coding environment.

Download PHPStorm Reference Card

Add .CTP extension in JetBrains PHPStorm

To add .ctp view file of CakePHP in PHPStorm editor you simply you just follow the following steps and you are done.

Step 1

Just go to File -> Settings to open editor’s settings panel.
PhpStorm support for CakePHP

Step 2: Just click ‘IDE Settings’ -> ‘File Types’

CakePHP ctp view file in PhpStorm

From the above image now just select ‘PHP Files’ from ”Recognized File Types’ and now from the ‘Registered Patterns’ section just click on ‘+’ icon add add *.ctp (according to the following image
CakePHP ctp view file in PhpStorm

Now just ‘Apply’ then ‘OK’… From now you can work with CakePHP view file (.ctp) inside JetBrains PHPStorm. Happy coding!!!

Also read how to add .CTP file extension in NetBeans. So it’s easy to work with CakePHP View file (.ctp) with all popular IDE.