Alias Overview
php5.3+ Support namespaces: namespace, one of the important functions of namespaces is that you can use aliases to refer to a rule-compliant name.
Namespaces support the form of alias references in 3 (or referred to as introduction): Class Alias, Interface (interface) alias, and Namespace (namespace) name alias.
php5.6+ also supports function aliases and constant aliases.
(Note: The Php.net website on the alias of this paragraph of the Chinese description of ambiguity and error, more as above) the specific grammatical format
Use xxx\xxx\xxx as XX;
So the use statement is actually an alias reference, not the usual import. Then the name that appears after the use has to be the alias that matches the rule. Errors and Causes
Now look at the error message similar to the title of the article:
"The use statement with Non-compound name ... has no effect"
We can understand this error message is that the name that appears in the USE statement is not a compound name and does not conform to the rule, so it is "no use."
Check that your statement is not directly following the use of the name of the class or interface, such as
Use News;
Modified to:
Use Yournamespace\news; (This is the same as use Yournamespace\news as News)
In the case of the YII2 framework, the alias reference for the typical data model is similar to the following:
Use App\models\news;
If it is Laravel, the alias reference is automatically completed because the App\models path has been added by default in composer.
So just make sure the class name is correct and no additional use statements are required.
When using frames, because the latest frameworks follow the PSR-4 automatic load naming conventions,
So be careful that the use of the underline (_) in the file, the path name, is automatically decomposed into multiple paths to match.
by Iefreer