0

use RingCentral\SDK;

or

require('/home/developer/workspace/ringcentral/demo/SDK.php');

Instead of using 'use' - php 5.6 command ,it is better to use require - php 5.3 ?

SDK class file contains following code

class SDK
{

const VERSION = '0.5.0';

/** @var Platform */
protected $platform;

/** @var Context */
protected $context;

public function __construct($appKey, $appSecret, $server)
{

    $this->context = new Context();

    $this->platform = new Platform($this->context, $appKey, $appSecret, $server);

}

public function getPlatform()
{
    return $this->platform;
}

public function getSubscription()
{
    return new Subscription($this->context, $this->platform);
}

public function getContext()
{
    return $this->context;
}

}
Anirudh Sharma
  • 7,968
  • 13
  • 40
  • 42
Ramkumar P
  • 196
  • 3
  • 13

2 Answers2

3

You have to require an autoloader to allow SPL autoload to resolve use statements:

// if you use Composer
require('vendor/autoload.php');
// or just require a PHAR
require('path-to-sdk/ringcentral.phar');

use RingCentral\SDK\SDK;

$sdk = new SDK(...);

You actually may omit use statement and use fully-qualified class name:

$sdk = new RingCentral\SDK\SDK(...);
DFuse
  • 140
  • 9
1

require() is used to require another file while use is used to use a class from another namespace, so those both commands are totally different and not comparable.

In your case you will need to use require() unless you are using any kind of autoloading like composer to make the class available in your file.

baao
  • 71,625
  • 17
  • 143
  • 203