Using classes without namespace with Yii2

I have issue similar to one discussed in topic . I want to use 2Checkout library and as suggested in referred topic I am trying to use one of its class as

$sale = new \Twocheckout_Sale();

but still I am not able to get it work and getting "Class not found error" .

Please suggest.

Install it via composer and that should take care of it because of the autoload.

I have installed it by composer


and one strange thing is if I try to manually include the file … it says cannot redeclare it . It shows that class is available with Yii but somehow I am unable to use it

Then you should be using 2Checkout\Twocheckout_Sale or something.

Read this:

php will not take interger in identifier .I have tried it just now

Then you should probably use a different library, preferably with more users:


There are quite a few alternatives, so if you’re not completely married to the lib, switch it out. :)


I would probably go for omnipay/omnipay …