Download the PHP package mrpix/cloudprintsdk without Composer
On this page you can find all versions of the php package mrpix/cloudprintsdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mrpix/cloudprintsdk
More information about mrpix/cloudprintsdk
Files in mrpix/cloudprintsdk
Package cloudprintsdk
Short Description This is the official PHP library to use the mpXcloudprint services.
License MIT
Informations about the package cloudprintsdk
MrpixCloudPrint SDK
This is the official PHP SDK of mr. pixel's CloudPrint service. This library contains methods to easily interact with the mpXcloudprint API. Below is a short instruction with some examples to get started with this SDK. For additional information, please visit our official documentation.
Installation
This library is not dependent to any http client like Guzzle. You can use any http client hat supports the php-http/client-implementation.
To get started quickly, install the cloudprint-sdk along with your favourite http client like Guzzle or Symfony Http Client:
Usage
This project depends on Composer. It is recommended to let the Composer autoloader automatically load all your dependencies. The example below will show you how to include the client for the mpXcloudprint API.
Authentication
Some actions require you to be authenticated. There are three options you can use for authentication.
-
Provide login credentials to CloudPrintClient constructor
The first option is to provide your login credentials when constructing the CloudPrintClient. To do this you have to hand over the username in the first argument and the password in the second argument.
However, using hardcoded login credentials is not secure. This method is perfect if you want to load credentials dynamically from some configuration. For static credentials, the recommended way is to use environment variables.
-
Environment Variables
If you don't provide your login credentials in the first option, the cloudprint SDK looks for environment variables. You can provide your credentials in the following environment variables:
-
Explicit login
The third option is to login with your credentials only if authentication is required. To do this, you have to call the login method before sending requests. Here is a example on how to do that:
Note: If the login credentials are not correct, the server will return a 401 or 403 response for all requests.
Test login credentials
To test if login credentials are correct, you can use the following example:
Insert a new printjob
The following section explains how to create a new printjob. It is recommended to create a new instance of an instruction. The request can be build by using the 'build' method of the instruction. By compiling the request, all given data will be automatically parsed to the required format by the API.
Template
The following example can be used to create a new printjob based on a pre-defined template:
Document
If you do not want to use a template, you can upload a whole document. To do that, you can use the following code:
All versions of cloudprintsdk with dependencies
psr/http-client Version ^1.0.1
php-http/client-common Version ^2.2.1
php-http/discovery Version ^1.19
php-http/multipart-stream-builder Version ^1.2
guzzlehttp/psr7 Version ^2.6
symfony/validator Version ^7.0
symfony/cache Version ^7.0
ext-json Version *
php-http/message Version ^1.16
nyholm/psr7 Version ^1.8