dtftao7249656 2017-03-31 04:58
浏览 21
已采纳

添加依赖于Slim 3 Framework

I'm new using Slim 3 Framework. I want to add this dependency faisalman/simple-excel-php. I installed via Composer but I don't know how to use it in my Controller. Do I need to add it to the container?

This is my composer.json file:

"require": {
    "slim/slim": "^3.8",
    "slim/php-view": "^2.2",
    "slim/twig-view": "^2.2",
    "illuminate/database": "^5.4",
    "faisalman/simple-excel-php": "^0.3.15"
},
"autoload":{
    "psr-4":{
        "App\\":"app"
    }
}

My project Structure is

  1. App

    1.1. Controllers

  2. Bootstrap

    2.1 app.php (here i instanse my app)

  3. vendor
  • 写回答

1条回答 默认 最新

  • duanfu1945 2017-03-31 06:31
    关注

    Having done a composer require faisalman/simple-excel-php, you now have the library installed in your application and available via autoload.

    The next step is using it.

    There is no direct need to integrate this library into the Slim DI container or worry about the bootstrap file. You can follow the example in the library's readme and instantiate directly:

    use SimpleExcel\SimpleExcel
    
    $excel = new SimpleExcel('CSV');
    $excel->parser->loadFile('test.csv');
    

    in whatever file makes the most sense for your project.

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

报告相同问题?

悬赏问题

  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符