dongzhuo3202 2019-03-14 14:56
浏览 93
已采纳

在同一名称空间中扩展供应商库

For example I have installed ExampleLibrary using composer. It has some drivers and they are placed under ExampleLibrary\Driver namespace.

ExampleLibrary\Driver\First, ExampleLibrary\Driver\Second, they are extending ExampleLibrary\DriverInterface

I want to create my own driver Third. Is it ok, if I will place my driver under the vendor namespace?

I will create directory src/ExampleLibrary/Driver/Third.php with namespace ExampleLibrary\Driver.

  • 写回答

1条回答 默认 最新

  • dongyi2425 2019-03-14 15:12
    关注

    You should not use vendors namespaces for your own classes. It is counterintuitive (it is harder to decide who is the author of this class - namespace no longer points vendor) and error-prone (ExampleLibrary may add ExampleLibrary\Driver\Third class at some point). It may also slow down autoloading (if you're using non-optimized autoloader).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持