php - How do I require a file or class in a vendor library in Yii2 that is not already included? -
i have class yii2 cannot see. other classes work. tried following. commented lines did not work.
// use app\vendor\googleads\googleads-php-lib\src\google\api\ads\common\util\errorutils; // require_once util_path . '/errorutils.php'; require_once('../vendor/googleads/googleads-php-lib/src/google/api/ads/common/util/errorutils.php'); use \errorutils;
this works, doesn't right. doesn't work in command mode, need.
$ yii cron php warning: uncaught exception 'yii\base\errorexception' message 'require_once(../vendor/googleads/googleads-php-lib/src/google/api/ads/common/util/errorutils.php): failed open stream: no such file or directory' in /cygdrive/c/users/chloe/workspace/xxx/models/googleadwords.php:36
how can require or use class in yii2?
the library use doesn't provide psr-4 autoloader settings classes. need add autoload classmap classes want load, composer.json in project's root directory following:
"autoload": { "classmap": [ "vendor/googleads/googleads-php-lib/src/google/api/ads/common/lib", "vendor/googleads/googleads-php-lib/src/google/api/ads/common/util" ] },
and in console: composer dump-autoload
this update composer autoloader. after you'll able call library classes with: \errorutils::getsourceoperationindex($error)
Comments
Post a Comment