Vinod VT
Vinod VT

Reputation: 7159

how to call a class function of an included php file Laravel 4

I have a php file plivo.php in app/plivo folder. This included in my controller like,

require app_path().'/plivo/plivo.php';

The plivo.php contains a class, RestAPI .

When I try to create an object like,

        $auth_id = "Your AUTH_ID";
        $auth_token = "Your AUTH_TOKEN";

        $p = new RestAPI($auth_id, $auth_token);

Produce an error:

Class 'Controllers\Account\RestAPI' not found

How can I create this object ?

Upvotes: 1

Views: 427

Answers (1)

Laurence
Laurence

Reputation: 60058

As your class is not namespaced - try and call it like this:

    $auth_id = "Your AUTH_ID";
    $auth_token = "Your AUTH_TOKEN";

    $p = new \RestAPI($auth_id, $auth_token);

Notice the \ before RestAPI

Upvotes: 4

Related Questions