Laravel/Composer: The use statement with non-compound name

前端 未结 1 651
生来不讨喜
生来不讨喜 2020-12-18 20:27

In my laravel project I created a model called CustomerLinks. The model resides in the app/models folder. My composer file has an autoload of:

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-18 20:42

    If you are not within a namespace (i.e. you are in the root namespace), and the class you want to use also is not in a namespace (i.e. also in the root namespace), then using use makes no sense, because the code will work the same without it. You are not importing anything with this statement.

    Composer has nothing to do with this, neither has any other autoloading. It's how PHP works by itself.

    0 讨论(0)
提交回复
热议问题