Search code examples
phpcodeigniterparse-platformcodeigniter-2php-5.6

Using parse API with codeigniter


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


Solution

  • 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();
        }
    }