Splunk SDK for PHP Examples

The Splunk SDK for PHP is deprecated. For more information, see Deprecation notice.

The Splunk® SDK for PHP provides several examples that show how to interact with Splunk, located in the /splunk-sdk-php/examples directory:

  • The Index (index.php) is the entry point for all examples, and attempts to connect to your Splunk server.
  • Search (search.php) runs a search using a query you provide, and shows how to create and read the results of an asynchronous search job.
  • List Saved Searches (list_saved_searches.php and saved_search.php) lists all saved searches, and lets you modify and delete saved searches.
  • List Jobs (list_jobs.php and job.php) lists all search jobs, and lets you run, pause, resume, finalize, and delete search jobs.

First, you'll need to set up a few things to run these examples:

  1. Install a local web server that supports PHP. We recommend the following web servers, depending on your operating system:

    • Mac OS X: MAMP
    • Windows: XAMPP
    • Linux: Apache and PHP from your package manager
  2. Move the entire /splunk-sdk-php directory to your web server's document root:

    • For MAMP, the root is /Applications/MAMP/htdocs/.
    • For XAMPP, the root is C:\xampp\htdocs\.
  3. In the /document_root/splunk-sdk-php/examples directory, make a copy of the settings.default.php file and name it settings.local.php. Update the Splunk login credentials with your own.

Now you should be able to access the SDK examples using a URL such as the one below (although you might have to change the port to 8080 or 80, depending on your web server):

http://localhost:8888/splunk-sdk-php/examples/index.php