Download the PHP package meritoo/limesurvey-api-client without Composer
On this page you can find all versions of the php package meritoo/limesurvey-api-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package limesurvey-api-client
Meritoo LimeSurvey API Client
Client of the LimeSurvey's API.
Installation
Run Composer to install this package in your project:
How to install Composer: https://getcomposer.org/download
Configuration of LimeSurvey
- Login to the LimeSurvey administration, e.g. using https://your-domain/admin address
- Go to menu:
Configuration
->Global settings
- Open
Interfaces
tab - For
RPC interface enabled
selectJSON-RPC
option - Enable
Publish API on /admin/remotecontrol
option
It should look like here: More information: https://manual.limesurvey.org/RemoteControl_2_API#Introduction
Usage
-
First of all you have to prepare configuration of connection and create instance of a client:
-
Next run the method which you would like:
- Finally grab data from result of called method:
Full code of this example:
Available methods
All available methods provides Meritoo\LimeSurvey\ApiClient\Type\MethodType
class as constants of the class. Examples:
Name of the method, actually constant of the MethodType
class, you should pass as 1st argument of \Meritoo\LimeSurvey\ApiClient\Client\Client::run()
method. Example:
Debug mode
In some cases more information may be required to fix bugs. The "debug" mode will help you do this. You can turn it on while preparing configuration of connection by passing true
as 4th argument of constructor:
The "debug" mode can be turned on if the instance of configuration exists by using the \Meritoo\LimeSurvey\ApiClient\Configuration\ConnectionConfiguration::setDebugMode()
method:
If you want to verify if if the "debug" mode is turned on simply call the \Meritoo\LimeSurvey\ApiClient\Configuration\ConnectionConfiguration::isDebugModeOn()
method:
Getting data from result
Verify if the result is empty
First of all you have to call required method to get result - instance of \Meritoo\LimeSurvey\ApiClient\Result\Result
class. The result allows you to get information if there is any data by calling the \Meritoo\LimeSurvey\ApiClient\Result\Result::isEmpty()
method:
Prepared/processed vs raw data
Result allows you to get data, the essence of calling API's method by calling the \Meritoo\LimeSurvey\ApiClient\Result\Result::getData()
method. This method accepts 1 bool argument:
false
- (default) prepared/processed data provided will be returnedtrue
- raw data will be returned
Prepared/processed data means instances of classes from Meritoo\LimeSurvey\ApiClient\Result\Item\*
namespace.
Attention.
- The above is true, if result provided by the API is iterable. Otherwise - instance of single item is returned.
Methods that provides iterable result:
- MethodType::LIST_PARTICIPANTS
- MethodType::LIST_QUESTIONS
- MethodType::LIST_SURVEYS
- MethodType::LIST_USERS
They are defined in
Meritoo\LimeSurvey\ApiClient\Type\MethodType::isResultIterable()
method.
Prepared/processed data
All instances are returned as elements of collection (instance of Meritoo\Common\Collection\Collection
class). Example:
If result provided by the API is not iterable, as mentioned above, instance of single item is returned. Example:
Raw data
An array with scalars or other arrays. Example:
Links
- LimeSurvey: https://www.limesurvey.org
- Composer: https://getcomposer.org
Enjoy!