Yii Framework Forum: Integrating Balanced Payments Php Library (Uses Namespaces) In Yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Integrating Balanced Payments Php Library (Uses Namespaces) In Yii Rate Topic: -----

#1 User is offline   rbot 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 30-November 12

Posted 30 November 2012 - 09:39 PM

I'm trying to integrated the Balanced Payments PHP library (github.com/balanced/balanced-php) into Yii.
The Balanced Payments lib uses PHP class namespaces, which I know is an issue with Yii. I'm trying to load it using the following:

$basePath = Yii::app()->getBasePath();

require_once($basePath . '/libraries/Balanced/vendor/httpful/bootstrap.php');
require_once($basePath . '/libraries/Balanced/vendor/restful/bootstrap.php');
require_once($basePath . '/libraries/Balanced/bootstrap.php');

I'm getting the following error:

Fatal error: Class 'RESTful\CEvent' not found in /protected/libraries/Balanced/vendor/restful/src/RESTful/Resource.php on line 10

CEvent is a core Yii class and it's looking for it in RESTful which is a vendor lib used by Balanced.

I tried using Yii::setPathOfAlias() as documented at yiiframework.com/doc/guide/1.1/en/basics.namespace#namespaced-classes but it did not work.

Can anyone help?
0

#2 User is offline   rbot 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 30-November 12

Posted 12 December 2012 - 07:54 PM

FYI for anyone struggling with importing a library that uses namespaces, this custom autoloader solved it for me:

https://gist.github.com/4234540
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users