PHPackages                             tourcms/tourcms-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. tourcms/tourcms-php

ActiveLibrary[API Development](/categories/api)

tourcms/tourcms-php
===================

TourCMS API wrapper for PHP

4.10.0(1y ago)9121.8k—6.1%9[3 issues](https://github.com/TourCMS/tourcms-php/issues)[3 PRs](https://github.com/TourCMS/tourcms-php/pulls)1MITPHPPHP &gt;=8.1

Since Aug 5Pushed 5mo ago13 watchersCompare

[ Source](https://github.com/TourCMS/tourcms-php)[ Packagist](https://packagist.org/packages/tourcms/tourcms-php)[ Docs](https://github.com/TourCMS/tourcms-php)[ RSS](/packages/tourcms-tourcms-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)DependenciesVersions (93)Used By (1)

PHP Wrapper for the TourCMS API
===============================

[](#php-wrapper-for-the-tourcms-api)

- [Installation](#installation)
    - [Installing via Composer](#installing-via-composer-recommended)
    - [Installing Manually](#installing-manually)
    - [Upgrading from v1.x](#upgrading-from-version-1x)
- [Usage](#usage)
- [Further examples](#further-examples)
- [Environment test](#environment-test)

Installation
------------

[](#installation)

### Installing via Composer (Recommended)

[](#installing-via-composer-recommended)

1. Install [Composer](https://getcomposer.org/), add `"tourcms/tourcms-php": "4.*",` to the `requires` section of your `composer.json`:
2. Ensure you are including composer's `autoload.php`, alternatively include `TourCMS.php` directly.

### Installing Manually

[](#installing-manually)

1. Download the source zip, extract to your web server
2. Include `TourCMS.php` in your source

### Upgrading from version 1.x

[](#upgrading-from-version-1x)

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](http://www.php-fig.org/psr/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

[](#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:

```
use TourCMS\Utils\TourCMS as TourCMS;
```

Your existing code should then work as-is, for example when you create a new instance of the TourCMS class you would have:

```
$tourcms = new TourCMS(0, 'YOUR_PASSWORD', 'simplexml');
```

#### Using the fully qualified name

[](#using-the-fully-qualified-name)

Alternatively use the fully qualified name when you create a new instance of the class:

```
$tourcms = new TourCMS\Utils\TourCMS(0, 'YOUR_PASSWORD', 'simplexml');
```

Usage
-----

[](#usage)

```
// Common configuration parameters

  // Marketplace ID will be 0 for Tour Operators, non-zero for Marketplace Agents
  // Agents can find their Marketplace ID in the API page in TourCMS settings
    $marketplace_id = 0;

  // API key will be a string, find it in the API page in TourCMS settings
    $api_key = "YOUR_KEY_HERE";

  // Timeout will set the maximum execution time, in seconds. If set to zero, no time limit is imposed.
    $timeout = 0;

  // Channel ID represents the Tour Operator channel to call the API against
  // Tour Operators may have multiple channels, so enter the correct one here
  // Agents can make some calls (e.g. tour_search()) across multiple channels
  // by entering a Channel ID of 0 or omitting it, or they can restrict to a
  // specific channel by providing the Channel ID
    $channel_id = 0;

// Create a new TourCMS instance
  // Optionally alias the namespace
  use TourCMS\Utils\TourCMS as TourCMS;
  $tourcms = new TourCMS($marketplace_id, $api_key, 'simplexml', $timeout);
  // 'simplexml' returns as a SimpleXMLObject
  // 'raw' returns the XML as as String

// Set a User-Agent
  $tourcms->set_user_agent('Example Tours Website');

// Call the API
  // Here as a quick example we search for some tours
  $result = $tourcms->search_tours('', $channel_id);

// Display the output
  print_r($result);
```

Further Examples
----------------

[](#further-examples)

### API documentation on tourcms.com

[](#api-documentation-on-tourcmscom)

Each API method in the [TourCMS API documentation](http://www.tourcms.com/support/api/mp/) includes full PHP sample code.

### Examples in this repository

[](#examples-in-this-repository)

Additionally there are some examples included in this repository, to run them:

1. Copy the `src/examples` directory to your web root
2. Rename `examples/config-example.php` to `examples/config.php`
3. Load your API credentials in the config file and ensure the path to `TourCMS.php` is correct
4. Point your web browser at the examples folder

Environment test
================

[](#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.

```
// Common configuration parameters

// Marketplace ID will be 0 for Tour Operators, non-zero for Marketplace Agents
// Agents can find their Marketplace ID in the API page in TourCMS settings
$marketplace_id = 0;

// API key will be a string, find it in the API page in TourCMS settings
$api_key = "YOUR_KEY_HERE";

// Channel ID represents the Tour Operator channel to call the API against
// Tour Operators may have multiple channels, so enter the correct one here
// Agents can leave this as 0 for the test
$channel_id = 0;

// Create a new TourCMS instance
// Optionally alias the namespace
use TourCMS\Utils\TourCMS as TourCMS;
$tourcms = new TourCMS($marketplace_id, $api_key, "simplexml");

// Call the environment test, the results will be displayed on the screen
$tourcms->test_environment($channel_id);
```

Response headers
================

[](#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.

```
$headers = $tourcms->get_last_response_headers();
$remaining_limit = $headers["x-ratelimit-remaining"];
```

Set User-Agent
==============

[](#set-user-agent)

Set a User-Agent header. Useful when trying to determine which application or process is making API calls.

```
$tourcms->set_user_agent("Example Tours Website");
```

Set X-Request-Identifier
========================

[](#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.

```
$tourcms->set_request_identifier("98b41172-4db9-464e-9db8-f31ae92ffbab");
```

Override base URL
=================

[](#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.

```
$tourcms->set_base_url("https://api.example.com");
```

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance56

Moderate activity, may be stable

Popularity40

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 78.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~75 days

Recently: every ~110 days

Total

53

Last Release

375d ago

Major Versions

1.x-dev → v2.0.02015-12-15

v2.0.4 → v3.0.02016-03-17

v3.14.0 → v4.0.02023-05-17

PHP version history (3 changes)v1.8PHP &gt;=5.2

v2.0.0PHP &gt;=5.3

v4.8.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/68dce33281563e97831b17e0787243bdb63db0862b39162bafd5c9ce0c44ff7c?d=identicon)[paulslugocki](/maintainers/paulslugocki)

---

Top Contributors

[![paulslugocki](https://avatars.githubusercontent.com/u/682719?v=4)](https://github.com/paulslugocki "paulslugocki (239 commits)")[![palisis-frmar](https://avatars.githubusercontent.com/u/117289119?v=4)](https://github.com/palisis-frmar "palisis-frmar (32 commits)")[![palisis-juanra](https://avatars.githubusercontent.com/u/22095456?v=4)](https://github.com/palisis-juanra "palisis-juanra (15 commits)")[![palisis-juancarlos](https://avatars.githubusercontent.com/u/169654869?v=4)](https://github.com/palisis-juancarlos "palisis-juancarlos (6 commits)")[![zaidapalisis](https://avatars.githubusercontent.com/u/20299512?v=4)](https://github.com/zaidapalisis "zaidapalisis (5 commits)")[![belen-palisis](https://avatars.githubusercontent.com/u/203636263?v=4)](https://github.com/belen-palisis "belen-palisis (5 commits)")[![MiguelMachadoPalisis](https://avatars.githubusercontent.com/u/18260532?v=4)](https://github.com/MiguelMachadoPalisis "MiguelMachadoPalisis (1 commits)")[![emarinpalisis](https://avatars.githubusercontent.com/u/97877683?v=4)](https://github.com/emarinpalisis "emarinpalisis (1 commits)")[![palisis-armando](https://avatars.githubusercontent.com/u/146739276?v=4)](https://github.com/palisis-armando "palisis-armando (1 commits)")

---

Tags

apitourcms

### Embed Badge

![Health badge](/badges/tourcms-tourcms-php/health.svg)

```
[![Health](https://phpackages.com/badges/tourcms-tourcms-php/health.svg)](https://phpackages.com/packages/tourcms-tourcms-php)
```

###  Alternatives

[m165437/laravel-blueprint-docs

API Blueprint Renderer for Laravel

22779.0k](/packages/m165437-laravel-blueprint-docs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
