Am I missing something?

Longtime Java dev, so I'm used to using Eclipse and clicking through objects, seeing the class inplementations and comments as well as auto complete on methods.

It seems with PHP Storm (and PDT/Sublime etc.) that autocompletion is really limited.
eg. Using Laravel I've got a class/method Input::get:

Screen Shot 2013-09-18 at 16.45.10.png

If I manually look, hit Open I can find Input and the method get just fine:
Screen Shot 2013-09-18 at 16.45.47.png

Am I missing something here?         

4 comments

Hi there,

Please show FULL content of such problematic file.

Am I missing something here?  

I think -- yes.

Most likely -- https://github.com/danielboendergaard/laravel-helpers

0

Input Code:
https://github.com/Pasvaz/laravel-skeleton/blob/master/laravel/input.php

Brands Code:

<?php
class Brands_Controller extends Base_Section_Controller
{
    public $table = 'brands';

    public $item_name = 'brands';

    public $DEFAULT_ORDER_BY = 'name';

    /**
     * Constructor
     *
     * @return void
     */
    public function __construct($attributes = array(), $exists = false)
    {
        parent::__construct($attributes, $exists);
    }

    /**
     * Get a collection
     */
    public function get_collection()
    {
        $order_by = Input::get('order_by', $this->DEFAULT_ORDER_BY);
        $per_page = Input::get('per_page', PAGINATION_PER_PAGE);

        $order = ( in_array( strtolower( Input::get('order') ), array('asc', 'desc') ) ) ? strtolower( Input::get('order') ) : DEFAULT_ORDER;

        $collection = null;

        $model = $this->model;
        $eager_load = array(
            'client',
            'brand_types'
        );

        $collection = $model::with($eager_load)
            ->order_by($order_by, $order)
            ->paginate($per_page);

        return $collection;
    }
}
0

Thank you.

Please see my updated answer.

The code completion in PhpStorm (and other tools mentioned by you) is NOT limited in this regard -- it's the way how this particular framework built/works (class autoloading).

"Input" class is indeed unknown to the IDE, because:

  1. There is no "Input" class at all -- the proper FQN is "Laravel\Input"
  2. The code does not import that class via "use" -- it loads it dynamically via autoloader (but allows such short (and much more convenient, for sure) form of usage)


Because of that, you need to tell IDE what "Input" class really is. The aforementioned "helper" file will solve it.

0

Thanks a lot, that helped a lot.

Ctrl+Click does take me to the ide_helper.php file rather than the implementation class directly but I guess it's liveable. One downside of the autocomplete though is that PHPStorm adds the full namespace rather than the shortened format which Laravel supports.

Still, a major improvement. More info I found in case it helps anyone:
http://forums.laravel.io/viewtopic.php?id=742

0

Please sign in to leave a comment.