douou6696 2018-07-09 22:10
浏览 64

Laravel - 通过composer安装包并在控制器中访问它

I have an laravel application and I need to install this package lunar-calendar

I install it and the package shows in vendor folder: enter image description here

The package documentation tells to required the package like this:

use yzha5\LunarCalendar;

I put this way but also try this in controller:

use App\yzha5\LunarCalendar;

but returns not found.

I also run the command to publish vendor but doesn't work.

How can I use this package?

  • 写回答

2条回答 默认 最新

  • dsq2015 2018-07-09 22:15
    关注

    The package doesn't contain a service provider, so publish vendor will accomplish nothing really.

    use yzha5\LunarCalendar; 
    \\ will not work because it isn't registered in your service provider that this alias equals the package path
    
    use App\yzha5\LunarCalendar; 
    \\ will not work because there isn't a folder in app directory named yzha5.
    

    Since it's just two classes and not exactly a decently build package, I'd just fetch those two files into a directory at your choosing, change the namespace and call them.

    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)