Download the PHP package floorplanner/roomstyler-api-php without Composer

On this page you can find all versions of the php package floorplanner/roomstyler-api-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package roomstyler-api-php

Roomstyler PHP API


This is a PHP library that makes it easier to use the Roomstyler RESTful API. It is intended to be a wrapper for the API so that you, as user of the API will never have to write your own HTTP requests but instead can simply call a method to do it for you.

Table of contents

Installation

Based on the roomstyler RESTful API, should anything be/remain unclear after reading the docs, check the documentation on there as well to see if it is more clear. Also, this is not a 1-on-1 copy of the API, some method calls are grouped (render for instance can do panorama, hq and 2d aside from the default 3d) or have a slightly more convenient way of adding parameters.

Manual (using GUI)

  1. Go to github.com/floorplanner/roomstyler-api-php
  2. Click on the Clone or download button
  3. Select Download ZIP
  4. Extract the .zip and move or copy it to the root of the project
  5. Require roomstyler-api-php-master/api/RoomstylerApi.php in your application

Manual (using git and command line)

This command clones the repository to project-root/roomstyler-api-php/, to require it add:

Composer (using command line)

Getting Started

Anonymous API access

When you want to read public data

User API access

For personal use, read global data or perform actions on rooms as the signed in user (whitelabel users can also login)

Whitelabel API access

For when you want to read global data and read, write or modify your own whitelabel data

Godmode API access

For the those who want to maximize their integration potential, this allows you to read and write and modify data of your whitelabel and your own rooms and perform actions on rooms as the signed in user

After doing this setup you should probably run a simple test to check if you can actually get a response back from a call.

More configuration options

We just talked about the user and whitelabel options that can be passed to the constructor of the RoomstylerApi class but there are more options:

Everything is already setup to work with the API so you barely have to change these settings. The option you'll most likely be using is debug which allows you to take a peek into the request.

Structure

This is a general overview of the structure of the core objects behind the API, I will try to explain what you can do and when you can do it as best as I can. The API is OOP only, which means you're going to have to apply a little bit of PHP's OOP but don't worry, it'll be easy!

RoomstylerApi

Starting with the RoomstylerApi class, this is the base for the entire API. It contains the settings and defaults that we've already discussed here

It also handles calls like this that you will be using:

If you're someone who has done OOP for some time and are familiar with PHP's magic methods and more specifically the __get magic method you'll know exactly what I'm talking about.

When you call something like ->components on the $api (Could be any variable name, must be an instance of the RoomstylerApi class) the $api will look up a class with the name of RoomstylerComponentMethods.

It does this by first converting whatever property you're trying to call to its singular form so components becomes component, then converting the first character to uppercase so component becomes Component and last but not least it prepends Roomstyler and appends Methods so that the final result becomes RoomstylerComponentMethods.

If you're already using the singular form of a word, e.g. component then the step to convert will do nothing and it will still uppercase the first character and prepend Roomstyler and append Methods

This RoomstylerComponentMethods class extends RoomstylerMethodBase and allows you to call the documented component aggregation methods.

Essentially this means that you can call any property and get either an instance of a class back if it exists and is included, or a Fatal Error: Class 'Roomstyler[NonExistentClass]Methods' not found in....

RoomstylerMethodBase

This is the base class behind the scenes that allows you to use any and all of the RoomstylerApi->_settings within an instance of Roomstyler[...]Methods It's purpose is to provide a standard interface for actions you execute to get a dataset.

RoomstylerModelBase

This is the base class behind the returned results from the requests. You use the methods in Roomstyler[...]Methods to get a set of results (through some find(), index() or search() action) after which you get a single object or an array of objects back which you can then manipulate.

Properties

This base class is actually more useful than the RoomstylerMethodBase since this one does the same and more, it also dynamically populates itself with properties returned from the API.

To get an idea of what I'm talking about, consider this json response from api/users/972691 it should look something like this:

And compare it to the return object that would look like this after a successful request and being __constructed

Now all the properties that start with an underscore (_) are also either :private or :protected which means we can't access them. If you try accessing this freshly fetched users _whitelabel property $user->_whitelabel it would simply return Notice: Undefined property: RoomstylerUser::$_whitelabel

If you tried to access the public (and dynamically populated) id on the other hand, you would get either NULL or it's value if it's set. The same goes for all other properties. Normally you would get a notice if you call a property that does not exist on an object ($user->non_existent_prop): Notice: Undefined property: RoomstylerUser::$non_existent_prop but since the fields are subject to change this would mean that you could get random Notice errors for no reason.

Because of this, all properties that do not exist or aren't public (except errors which is made public through __get) will return NULL.

Methods

The RoomstylerModelBase class also provides us with some other methods we can use to see wether the object actually exists() (not just an empty object - but actually having properties), or if the object in question has any errors

This is done (using our $user initiated on top) by calling $user->errors which will return a RoomstylerError object or $user->exists() to check if any property is set at all.

Errors

Every object returned from the API will have an accessible errors property that has a few methods. To check wether any of the objects contains any error (including http errors)

the maximum limit of the index call is 50. if this is exceeded the server will return a JSON error and an Unprocessable Entity (422) http error

To access these errors, call the errors property on a single entity. It will return an instance of the RoomstylerError class.

RoomstylerError

The RoomstylerError class has three methods, one to get() all the errors. One to see if there are each() error.

They will be explained using this example request.

(This request will error out since the max. limit for the index() function is 50)

Check if there are errors

The any() function will return true if any errors including any http errors occured.

Get all errors

The get() function will return an array of errors including http errors. If there are no errors, an empty array is returned.

The array returned is associative and will contain numeric and string keys. As you might be able to see below, the errors have different depths making it hard to property loop the errors. The solution for this is the builtin each() method which is explained later.

Loop all the errors

If there are errors, you can loop these through the each() function. It takes one parameter, which is a closure or callable function that itself takes one (optionally two) parameter(s) The first parameter contains the error message of an error and the second parameter will contain it's parent keys if it was a nested hash.

As we know the above $response example gives us two errors, one through a nested json object with an error key which contains the error. And a http error since we're requesting too much data.

If we'd print the get() function with this example, the errors array would look like this:

Knowing the structure of the errors, if we build something like this:

The output will look like this:

If the error key wasn't an error but instead another hash with say a quantity key containing the same error, the output for the same request would look like:

API endpoints

Rooms

Aggregation

Getting search meta data

PHP snippet

Method signature

Parameters

Fetching rooms

PHP snippet

Method signature

Parameters

Fetching whitelabel rooms

This method accepts the same parameters as the non-scoped index method! The only difference is that the optional whitelabel parameter is set to the whitelabel user for you

PHP snippet

Method signature and parameters: see Fetching Rooms

Finding a specific room

PHP snippet

Method signature

Parameters

Searching rooms

PHP snippet

Method signature

Parameters

Fetching panoramas

PHP snippet

Method signature

Parameters

Actions

Lets say Let's initialize a $room variable and use that in the following requests like so:

Fetching a room panorama

PHP snippet

Method signature

Parameters

Comment on a room

PHP snippet

Method signature

Parameters

Toggle love on a room

PHP snippet

Method signature

Parameters

Change owner of a room

PHP snippet

Method signature

Parameters

Delete a room

PHP snippet

Method signature

Parameters

Fetch products used in the room

PHP snippet

Method signature

Parameters

Fetch users loves of the room

PHP snippet

Method signature

Parameters

Fetch related rooms of a room

PHP snippet

Method signature

Parameters

Fetch comments on a room

PHP snippet

Method signature

Parameters

Add tags to a room

PHP snippet

OR

Method signature

Parameters

Remove tags from a room

PHP snippet

OR

Method signature

Parameters

Render room in 2D, 3D, HD 3D or panorama

PHP snippet

Method signature

Parameters

Users

Aggregation, Creation and Login

Finding users

PHP snippet

OR

OR

Method signature

Parameters

Create a user

PHP snippet

Method signature

Parameters

Login

If you read over the user access setup section I showed an example of logging in as a user within the constructor of the object. It is however, also possible to login seperately like this, if You didn't login before and call this function manually later, all requests from then on will have user access.

This function also returns the token needed to use in other requests such as to comment or love a room.

Also, if you're already logged in you do not need to use this function.

PHP snippet

Method signature

Parameters

Actions

Let's initialize a $user variable and use that in the following requests like so:

Delete a user

Deletes a given user

PHP snippet

Method signature

Parameters

Get user loved rooms

PHP snippet

Method signature

Parameters

Get user collections

PHP snippet

Method signature

Parameters

Get specific user collection

PHP snippet

Method signature

Parameters

Contests

Aggregation

Fetch contests

PHP snippet

Method signature

Parameters

Fetch a contest

PHP snippet

Method signature

Parameters

Actions

Let's initialize a $contest variable and use that in the following requests like so:

Fetch contest entries

PHP snippet

Method signature

Parameters

Contest entries

Actions

Let's initialize a $contest_entry variable and use that in the following requests like so:

Vote for a contest entry

PHP snippet

Method signature

Parameters

Material

Aggregation

Find a material item

PHP snippet

Method signature

Parameters

Component

Aggregation

Find a component item

PHP snippet

Method signature

Parameters

Categories

Aggregation

Fetching categories

PHP snippet

Method signature

Parameters

3dplanner

Embedding the 3dplanner

PHP snippet

Method signature

Parameters


All versions of roomstyler-api-php with dependencies

PHP Build Version
Package Version
Requires php Version >=5.0.0
ext-curl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package floorplanner/roomstyler-api-php contains the following files

Loading the files please wait ....