How to use PHPExcel correctly with Symfony 2

前端 未结 6 1881
情话喂你
情话喂你 2020-12-24 09:51

I need to use PHPExcel with a Symfony2 project. Anyone know how to set up the project correctly to use the library? Should i put it in the vendor directory? Wha

6条回答
  •  失恋的感觉
    2020-12-24 10:13

    If you are using composer to manage your project, you can just change the composer.json file:

    "autoload": {
        "psr-4": {
            "": "src/",
            "": "vendor/phpoffice/phpexcel/Classes/"
        },
        "classmap": [
            "app/AppKernel.php",
            "app/AppCache.php"
        ]
    },
    

    Then add

    use PHPExcel;
    use PHPExcel_IOFactory;
    

    to your controller file, and you can use the PHPExcel like this:

    $objPHPExcel = new PHPExcel();
    

    Hope it helps.

提交回复
热议问题