简体   繁体   中英

Can anyone tell how to include custom libraries in Zend Framework 3?

I have tried the way they used to include in Zend Framework 2 but it gives me an error

Fatal error: Class 'Lib\\FusionCharts' not found in /var/www/html/skeleton/module/Album/src/Controller/AlbumController.php on line 13

You must include path of your library before use :

/** Include path **/
ini_set('include_path', ini_get('include_path').';<relative directory path from this file>/');

/** PHPExcel */
include 'fusioncharts.php';

$objFusionCharts = new FusionCharts();

Alternatively, if you use composer, you can add the path to your library Lib in the autoload-psr4 section of your composer.json .

"autoload": {
    "psr-4": {
        "Lib\\": "relative/directory/path/from/your/baseDir"
    }
},

Then run :

composer dump-autoload

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM