Download the PHP package tourcms/tourcms-php without Composer
On this page you can find all versions of the php package tourcms/tourcms-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tourcms/tourcms-php
More information about tourcms/tourcms-php
Files in tourcms/tourcms-php
Package tourcms-php
Short Description TourCMS API wrapper for PHP
License MIT
Homepage https://github.com/TourCMS/tourcms-php
Informations about the package tourcms-php
PHP Wrapper for the TourCMS API
- Installation
- Installing via Composer
- Installing Manually
- Upgrading from v1.x
- Usage
- Further examples
- Environment test
Installation
Installing via Composer (Recommended)
- Install Composer, add
"tourcms/tourcms-php": "4.*",
to therequires
section of yourcomposer.json
: - Ensure you are including composer's
autoload.php
, alternatively includeTourCMS.php
directly.
Installing Manually
- Download the source zip, extract to your web server
- Include
TourCMS.php
in your source
Upgrading from version 1.x
If you are upgrading from version 1.x of the library the latest TourCMS.php
should be more or less a straight swap. The major change being that to adhere to PHP PSR-4 standards, the class is now namespaced. Broadly speaking there are two different ways to update existing code to account for this:
Aliasing the namespace
If you already have a global include file that includes TourCMS.php
you could add the following line immediately after TourCMS.php
is included:
Your existing code should then work as-is, for example when you create a new instance of the TourCMS class you would have:
Using the fully qualified name
Alternatively use the fully qualified name when you create a new instance of the class:
Usage
Further Examples
API documentation on tourcms.com
Each API method in the TourCMS API documentation includes full PHP sample code.
Examples in this repository
Additionally there are some examples included in this repository, to run them:
- Copy the
src/examples
directory to your web root - Rename
examples/config-example.php
toexamples/config.php
- Load your API credentials in the config file and ensure the path to
TourCMS.php
is correct - Point your web browser at the examples folder
Environment test
The library can attempt to check your local environment and API credentials, useful if you are having trouble connecting. First off make sure you are including TourCMS.php
, either via autoload or explicitly.
Response headers
TourCMS responds with some useful information in the response headers. There is a method to retrieve the last set of response headers via the PHP wrapper.
Set User-Agent
Set a User-Agent header. Useful when trying to determine which application or process is making API calls.
Set X-Request-Identifier
Set a uuid or other id to the request. Useful for tracking/logging. Should be pseudo random / unique, e.g. UUID.
Override base URL
By default the base URL will point to TourCMS main production environment. There is a method to override this to point at another base URL, intended for testing purposes.