Slim Dependency Injection Auto-completes for Komodo Edit/IDE

Dependency Injections are resolved by frameworks at runtime. Editors, on the other hand, are not so powerful to understand such dependencies. I encountered the same with Slim Framework and found a hack for komodo edit autosuggest/autocomplete.






It has been a long time since I wrote my last blog post. I have been busy, got married and switched jobs.

Well, during the research while developing an API for my current client, I came to know about Slim Framework. It is a micro-framework, which is very powerful and flexible. As far as my editor is concerned, I have been a fan of Komodo Edit since 2009.

Komodo Edit is one of the best editor and has real cool font display when it comes to cross platform compatibility. I tried using phpStorm too. Although I found it really good, the fonts were too painful for the eyes.

As you must know, dependency injection is a dynamic assignment of a service to a dependent object. Most of the frameworks have this capability. What editors/IDEs don't have, is the capability to somehow guess the objects of the service attached. Therefore, they are not able to provide autosuggest.

I posted this problem both on Slim Forum and Komodo. A good solution was posted by one of the users with git username "silentworks," I met on Slim IRC channel.

Solution: https://gist.github.com/silentworks/bacfc76b63b9f76b5c2c

My File Setup:

slim framwork File setup

I created App.php file Library folder and used as the solution posted.

<?php
namespace Library;

/**
 * @property \Library\Helper $helper
 * @property \Model\Common $common
 * @property \Controller\General $general
 * @property \Controller\Treatment $treatment
 */
class App extends \Slim\Slim {}

Thats it.

You must have auto-suggests/completes working like

use Library\App;
$app = new Library\App();
$app->helper-> // this shows autosuggest/autocomplete the class members from HELPER

The problem that still remains unsolved, even on phpstotm is

use Library\App; 
$app = App::getInstance();
$app->helper-> // does not show anything

Comments and improvements are welcomed.

Thank you