Support the ongoing development of Laravel.io →
Configuration Database Architecture
Last updated 2 years ago.
0

I recently decided to do something similar and I did the due diligence on finding out how to use parse.com alongside laravel 4.*, it's a book that doesn't cost much: https://leanpub.com/building-web-applications-using-parse-rest-api

I didn't write it, but I bought it, and it taught me all I needed to know! Very comprehensible stuff.

Last updated 2 years ago.
0

Here is a sample pdf of the book I found that actually tells you how to download the php sdk to laravel through composer:http://samples.leanpub.com/building-web-applications-using-parse-rest-api-sample.pdf

Last updated 2 years ago.
0

Parse.com has now an official PHP SDK released, this book is using the PHP third party build on the REST API... is this book still great for learning it the right way?

Last updated 2 years ago.
0

For the sake of using Laravel with Parse.com I think using the book would be your best bet IF you are crunched for TIME since they've worked out any kinks of getting every bit of the API available to you.

In regards to their new SDK, there are numerous yet tedious ways to implement sdks. Since Laravel is a framework, you can still use conventional php practices alongside of it to get what you want done, or use composer to do some lifting for you.

For example the most simple way to do this, if you wanted to use a specific class from the SDK, you could reference it via composer:

"autoload": {
    "classmap": [
        "app/commands",
        "app/database/migrations",
        "app/database/seeds",
        "app/parseSDK/WhateverClassFile.php"
    ],
    ....

then run: composer dump-autoload

Last updated 2 years ago.
0
Solution

you can just require it using composer :

composer require "parse/php-sdk:1.0.*"

then you can use it with your app directly, and the way to do so is just to use classes you want to deal with it so you can do like this :

in BaseController.php you can add the initialize so that your session will be always initiated with parse like for example:

<?php

use Parse\ParseClient;

class BaseController extends Controller {
    
    public function __construct()
    {
        parent::__construct();
        ParseClient::initialize('WXqBC7vBV9Ag1p8wuM', 'vlxhvPiDjOy5kpc79HRyJvEL', 'UjqrssNWJ');
    }

}

and your controller will be like :

<?php

use Parse\ParseClient;
use Parse\ParseObject;
use Parse\ParseException;

class PagesController extends BaseController {

    public function showWelcome()
    {

        $object = ParseObject::create("TestObject");
         
        $object->set("elephant", "php");
        $object->set("today", new DateTime());
        $object->setArray("mylist", [1, 2, 3]);
        $object->setAssociativeArray(
          "languageTypes", array("php" => "awesome", "ruby" => "wtf")
        );
         
        try {
          $object->save();
          return View::make('index')->with($object->getObjectId());
        } catch (ParseException $ex) {  
          // Execute any logic that should take place if the save fails.
          // error is a ParseException object with an error code and message.
          throw new Exception('Failed to create new object, with error message: ' + $ex->getMessage());
        }

        return View::make('index');
    }

}

there are no need to use $object->getObjectId(); as it will return null since you didnt save the object yet (https://github.com/ParsePlatform/parse-php-sdk/blob/master/src/Parse/ParseObject.php#L393) and

$php = $object->get("elephant");

is used to get the value of the elephant field from Parse object, and since your creating a new one, you dont need for it when creating a new object.

am still trying to figure out how to work with Parse SDK.

if you have any question about https://leanpub.com/building-web-applications-using-parse-rest-api am happy to answer your question or help you with it (as am the author of this book) my email is z[@]zah.me

and I have started to write a new book https://leanpub.com/building-web-applications-using-parse-php-sdk which will cover the use of Parse PHP SDK instead of the 3ed party library I used to use.

Last updated 2 years ago.
0

Thank you so much, linuxjuggler!

I had some difficulty trying to figure this out.

Last updated 2 years ago.
0

am glad that I helped you out

have good time coding josantana

Last updated 2 years ago.
0

linuxjuggler said:

am glad that I helped you out

have good time coding josantana

I'm just buy it few days ago, can we upgrade the book for a special price? ;-) I'm now sometimes confuse with the difference between the 2 SDK's / Library

ps, in the new book also how to login and other user auth thru parse.com PHP SDK, so no need for a mysql database anymore

Last updated 2 years ago.
0

I think I will provide the paid readers of my old book a discount code to use if they want to get the new book.

the new book, is going to be based on Parse Core, so am not going to use mySQL nor any other data source, hopefully I will have the time to continue with it soon.

at the end Happy coding

Last updated 2 years ago.
0

Happy coding, your help is great ;-)

Fred

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.