The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

Dependency Injection autosuggest for Komodo Edit

smstoharpreet's Avatar

smstoharpreet

03 Jun, 2015 03:49 PM

  1. Support Staff 1 Posted by Andrew Smith on 03 Jun, 2015 04:08 PM

    Andrew Smith's Avatar
  2. 2 Posted by smstoharpreet on 05 Jun, 2015 10:28 AM

    smstoharpreet's Avatar

    the code works fine. But its works for this

    <?php
    $app = new Library\App();
    $app->helper-> // this should autocomplete now
    
    but not for
    <?php
    $app = new Library\App::getInstance();
    $app->helper-> // does not show
    

    UPDTED CODE

  3. Support Staff 3 Posted by Andrew Smith on 05 Jun, 2015 10:36 AM

    Andrew Smith's Avatar

    Thats not valid PHP code. You cannot call a new getInstance unless getInstance is an actual class name.

  4. 4 Posted by smstoharpreet on 05 Jun, 2015 10:39 AM

    smstoharpreet's Avatar

    if change the class to something like

    /**
     * @property \Library\Helper $helper
     * @property \Model\Common $common
     * @property \Controller\General $general
     * @property \Controller\Treatment $treatment
     /
    class App extends \Slim\Slim {
        public static $instance;
        public function __construct() {
            self::$instance = $this;
        }
        /*
         * function to get instance of current class
         * @return  object
    */ public static function getInstance($name="default") { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; } }
    I get an error

    Fatal error: Call to a member function set() on a non-object in /var/www/html/lyfboatapi/lyfboat/api/vendor/slim/slim/Slim/Slim.php on line 239

  5. Support Staff 5 Posted by Andrew Smith on 05 Jun, 2015 10:43 AM

    Andrew Smith's Avatar

    You class is called App not getInstance.

    Also that error is related to something else as there is no set method in Slim.php. You would need to call $app->container->set();

  6. 6 Posted by smstoharpreet on 05 Jun, 2015 10:45 AM

    smstoharpreet's Avatar

    see the code above and updated code.
    code is italic coz markdown removed one *

  7. Support Staff 7 Posted by Andrew Smith on 05 Jun, 2015 10:47 AM

    Andrew Smith's Avatar

    If you are calling a static method, you cannot have the new keyword before it. The code should look like:

    <?php
    $app = Library\App::getInstance();
    $app->helper-> // does not show
    

    And that should work.

  8. 8 Posted by smstoharpreet on 05 Jun, 2015 10:50 AM

    smstoharpreet's Avatar

    it was a mistake, removing NEW does not help either.

  9. 9 Posted by smstoharpreet on 05 Jun, 2015 10:52 AM

    smstoharpreet's Avatar

    there are two problems
    first autocomplete does not work
    and even if i try running the code i get error

    Fatal error: Call to a member function set() on a non-object in /var/www/html/lyfboatapi/lyfboat/api/vendor/slim/slim/Slim/Slim.php on line 239

  10. Support Staff 10 Posted by Andrew Smith on 05 Jun, 2015 10:53 AM

    Andrew Smith's Avatar

    One problem at a time.

    Yeah because your return docblock in the getInstance method says object rather than \Library\App. An object can be anything, its not specific enough for your IDE to work it out.

    I addressed the previous issue here http://help.slimframework.com/discussions/problems/10066-dependency...

  11. 11 Posted by lobebowi on 05 May, 2017 06:40 AM

    lobebowi's Avatar

    I will buy a Kodak Camera for my family.
    http://www.reviewshut.com/unlock-your-hip-flexors-review/

  12. 12 Posted by cokubafo on 06 May, 2017 06:41 AM

    cokubafo's Avatar

    We will auto adjust the screen.
    http://menobsession.com/

  13. 13 Posted by umts on 05 Jun, 2017 10:56 AM

    umts's Avatar

    I really love this concept. I will share it with my friends. Pure Natural Healing by Master Lim

  14. 14 Posted by nqvs on 06 Jun, 2017 07:45 AM

    nqvs's Avatar

    This is good for Komodo users. Heartburn No More - Reviewshut

  15. 15 Posted by bour on 07 Jun, 2017 07:21 AM

    bour's Avatar

    I will try to learn more about this Komodo. I have mentioned about this site

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac