Reputation: 389
I'm trying to get parse to work with codeIgniter's function but it seems that in functions i have to type use quotes whenever i use the use operator
This is what I am suppose to use:
require 'vendor/autoload.php';
use Parse\ParseClient;
ParseClient::initialize('secret', 'secret', 'secret');
use Parse\ParseObject;
$testObject = ParseObject::create("TestObject");
$testObject->set("foo", "bar");
$testObject->save();
I tested and it works perfectly without codeIgniter class and functions.
Problem occurs here when i try to put it in a class
<?php
class MY_Composer
{
function __construct()
{
require './vendor/autoload.php';
use Parse\ParseClient;
ParseClient::initialize('secret', 'secret', 'secret');
use Parse\ParseObject;
$testObject = ParseObject::create("TestObject");
$testObject->set("foo", "bar");
$testObject->save();
}
}
Please help me solve this as I want to use this interesting API
https://www.parse.com/apps/quickstart#parse_data/php
Upvotes: 3
Views: 1797
Reputation: 389
Thanks but I managed to figure this out myself... put do post any answer you guys think that is better than this :D Happy programming. Cheers
require './vendor/autoload.php';
use Parse\ParseClient;
use Parse\ParseObject;
ParseClient::initialize('secret', 'secret', 'secret');
class MY_Composer
{
function __construct()
{
$testObject = ParseObject::create("TestObject");
$testObject->set("foo", "bar");
$testObject->save();
}
}
Upvotes: 2
Reputation: 108
use
not works because it always must be placed on the start on php file.
put it on first line after php tag it works properly, like this:
<?php
require './vendor/autoload.php';
use Parse\ParseClient as ParseClient;
use Parse\ParseObject as ParseObject;
class MY_Composer
{
function __construct()
{
ParseClient::initialize('secret', 'secret', 'secret');
$testObject = ParseObject::create("TestObject");
$testObject->set("foo", "bar");
$testObject->save();
}
}
Upvotes: 1