PHP code example of ordersaga / php-sdk

1. Go to this page and download the library: Download ordersaga/php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ordersaga / php-sdk example snippets


//instantiate the User and Company objects from the SharedObjects folder
$user = new User(); //or User::create()
$company = new Company(); //or Company::create()

//set values (generally from a user submitted form)
//it's a very good idea to perform your own validation on this data prior to setting it
$user->setFname($_POST['fname']);
$user->setLname($_POST['lname']);
$user->setEmail($_POST['email']);

$company->setName($_POST['company']);

$user->setCompany($company);

//instantiate the user endpoint 
$user_sdk = new UserEndpoint(); //or UserEndpoint::create()

//an exception will be thrown if anything other than a 200 is returned
//an updated User object is returned on success
$new_user = $user_sdk->addUser($user);

$guest = new Guest();
$guest->setFname('Bob');
$guest->setLname('Jenkins');
$guest->setEmail('[email protected]');

$guest = (new GuestEndpoint())->addGuest($guest);

//or

$guest = (new GuestEndpoint())->addGuest();

composer