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 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含