The [[http://​www.workxpress.com/​sites/​default/​files/​api/​Services_WorkXpress_Project.tar.gz|Services WorkXpress Project]] archive contains all of the files required to make API calls to a WorkXpress application using the [[Dev Resources - Services WorkXpress|Services WorkXpress PHP Package]]. ​

* WXQuery.php //- Paired with the WXQueryElement object, these objects are used to generate Query XML.//

+

* WXQueryElement.php

+

* wx_query_constants.php

+

* /Request

+

* AddItem.php //- The Request_AddItem class handles the XML for an AddItem request.//

+

* ExecuteAction.php //- The Request_ExecuteAction class handles the XML for an ExecuteAction request.//

+

* LookupData.php //- The Request_LookupData class handles the XML for an LookupData request.//

+

* UpdateItem.php //- The Request_UpdateItem class handles the XML for an UpdateItem request.//

+

* /Response

+

* AddItem.php //- The Response_AddItem class handles the XML for an AddItem response.//

+

* ExecuteAction.php //- The Response_ExecuteAction class handles the XML for an ExecuteAction response.//

+

* LookupData.php //- The Response_LookupData class handles the XML for an LookupData response.//

+

* UpdateItem.php //- The Response_UpdateItem class handles the XML for an UpdateItem response.//

+

* /examples

+

* add_item.php //- An example of how to use AddItem using objects to setup the call.//

+

* add_item_array.php //- An example of how to use AddItem using an array to setup the call.//

+

* execute_action.php //- An example of how to use ExecuteAction using objects to setup the call.//

+

* execute_action_array.php //- An example of how to use ExecuteAction using an array to setup the call.//

+

* lookup_data.php //- An example of how to use LookupData using objects to setup the call.//

+

* lookup_data_array.php //- An example of how to use LookupData using an array to setup the call.//

+

* update_item.php //- An example of how to use UpdateItem using objects to setup the call.//

+

* update_item_array.php //- An example of how to use UpdateItem using an array to setup the call.//

+

* /XML

+

* Parser.php //- Pear's XML_Parser class.//

+

* Unserializer.php //- Pears XML_Unserializer class.//

+

* /scripts //- a folder for any script that's meant to be executed at the command line.//

+

* test.php //- A test file that will perform necessary includes to check and make sure everything is set to go. //

+

* /web //- a folder for any file to be accessed from the web.//

+

+

Next, we'll walk through each of the files that are not covered in the Services WorkXpress documentation and explain why they exist and what we use them for.

+

+

===== /​scripts/​test.php =====

+

<code php><?​php

+

+

define('​BASE_PATH',​ dirname(dirname(__FILE__)));​

+

include_once(BASE_PATH . '/​inc/​config.php'​);​

+

+

echo "​BASE_PATH:​ " . BASE_PATH . "​\n";​

+

echo "Test was successful.\n";​

+

+

?></​code>​

+

+

Execute the /​scripts/​test.php file via command line using the PHP CLI library. ​ You can do this in linux by doing the following (let's assume your project files are in /​var/​newproject):​

+

+

''>​ cd /​var/​newproject

+

> php scripts/​test.php

+

BASE_PATH: /​var/​newproject

+

Test was successful.''​

+

+

What this test script does is it includes the inc/​config.php file, which in turn includes the Services WorkXpress libraries. ​ If you see the line "Test was successful"​ at the end of the script, then you know there were no problems with includes or missing dependencies. ​ It also shows the value for the BASE_PATH constant, which can be used in any /web or /script PHP file to mean the base of your project folder. ​ This is extremely useful when doing includes. ​ If you do not see the BASE_PATH, or the "Test was successful"​ line at the end then there was an error processing the script. ​ Check your phpcli error log for details and resolve.

+

+

===== /​inc/​config.php =====

+

<code php><?​php

+

+

set_include_path('​.'​ . PATH_SEPARATOR . BASE_PATH.'/​lib/​pear'​);​

+

+

include_once('​Services/​WorkXpress.php'​);​

+

+

?></​code>​

+

+

In this file you will take care of including everything you write in the /lib folder, making them available in any of your scripts. ​ It will also contain the definition of any variables that you want to be available script by script as you go on. In it's earliest form here it only includes Services WorkXpress, but you haven'​t written any code yet. Here's an example of an /​inc/​config.php file from a complete project, with includes and configuration variables global to the application:​