0

When looking up the documentation of yii it is straightforward to find the class or method to solve a particular problem, but how do you know what 'use' statement to place in your code?

I'm looking for statements like:

use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;

For example, the CDateTimeParser class has this information:

http://www.yiiframework.com/doc/api/1.1/CDateTimeParser
Package:        system.utils
Inheritance:    class CDateTimeParser
Since:          1.0
Source Code:    framework/utils/CDateTimeParser.php

What should the 'use' statement be?

audioppy
  • 5
  • 3

1 Answers1

0

The same with Yii 2 documentation. You should check class reference.

The available classes are placed in the left menu, grouped by namespace and sorted in alphabetical order. Or you can find them with autocomplete search at the top of the page. In the detailed page you can see full class name including namespace in the header. Other information that you mentioned (inheritance, availability since version, source code link) is also available.

For example the information about yii\web\Controller is located here. And in your code with use statement it will be:

use yii\web\Controller;

Also you can look at the source code of framework or just use IDE autocomplete and auto import as suggested above in the comments.

arogachev
  • 33,150
  • 7
  • 114
  • 117