I used this in the API to connect my PHP web application to SharePoint and transfer data from PHP to SharePoint, for me it worked 100%:
Instructions for use :
Installation
Download the WSDL file for the SharePoint lists you want to interact with. This can usually be obtained at: sharepoint.url/subsite/_vti_bin/Lists.asmx?WSDL
If you are using composer, just add thybag / php-sharepoint-lists-api to your composer.json and run composer.
{ "require": { "thybag/php-sharepoint-lists-api": "dev-master" } }
If you are not using composer, you can manually download a copy of the SharePoint API files and include the top class "SharePointAPI.php" in your project.
Create a SharePointAPI Object
To use the PHP SharePoint List APIs, you need a valid user / service account with the permissions for the required list.
For most SharePoint installations, you can create a new instance of the API using:
use Thybag\SharePointAPI; $sp = new SharePointAPI('', '', '');
If your installation requires NTLM authentication, you can use:
use Thybag\SharePointAPI; $sp = new SharePointAPI('', '', '', 'NTLM');
SharePoint Online users should use:
use Thybag\SharePointAPI; $sp = new SharePointAPI('', '', '', 'SPONLINE');
All methods return an array by default. SetReturnType can be used to indicate that results should be returned as objects.
Reading from the list.
To return all items from a list, use either
$sp->read('');
or
$sp->query('')->get();
To return only the first 10 items from a list, use:
$sp->read('', 10);
or
$sp->query('')->limit(10)->get();
To return all items from a list where Smith's last name is, use:
$sp->read('', NULL, array('surname'=>'smith'));
or
$sp->query('')->where('surname', '=', 'smith')->get();
List request
You can use the query method when you need to specify a complex query that can be easily determined using read methods. Queries are built using a number of (hopefully expressive) pseudo SQL methods.
For example, if you want to request a list of pets and return all dogs under 5 years of age (sorted by age), you can use them.
$sp->query('list of pets')->where('type','=','dog')->and_where('age','sort('age','ASC')->get();
If you want to get the first 10 animals that were cats or hamsters, you can use:
$sp->query('list of pets')->where('type','=','cat')->or_where('type','=','hamster')->limit(10)->get();
If you need to return 5 items, but including all the fields contained in the list, you can use. (pass false to all_fields to enable hidden fields).
$sp->query('list of pets')->all_fields()->get();
If you have a CAML set for a specific extended request that you want to execute, you can pass it to the request object using:
$sp->query('list of pets')->raw_where('Hello World')->limit(10)->get();
Add to list
To add a new item to the list, you can use the "write", "add" or "insert" method (all functions are the same). Creating a new entry in the list with the columns first name, last name, age and phone may look like this:
$sp->write('', array('forename'=>'Bob','surname' =>'Smith', 'age'=>40, 'phone'=>'(00000) 000000' ));
You can also start several write operations using:
$sp->writeMultiple('', array(array('forename' => 'James'),array('forename' => 'Steve')));
Line editing
To edit a line you need to have its identifier. Assuming the above line has an identifier of 5, we can change Bob's name to James with:
$sp->update('','5', array('forename'=>'James'));/code>
As with the write method you can also run multiple update operations together by using:
$sp->updateMultiple('', array( array('ID'=>5,'job'=>'Intern'),array('ID'=>6,'job'=>'Intern')));
When using updateMultiple, each element MUST have an identifier.
Delete lines
To delete a line, an identifier is required, as well as a list name. To delete an entry for James with id 5, you should use:
$sp->delete('', '5');
If you want to delete several records at once, the ID array can also be passed to several delete methods
$sp->deleteMultiple('', array('6','7','8'));
Helper Methods
The PHP SharePoint API contains several helper methods that make it easy to ensure that certain values have the correct format for some special SharePoint data types.
dateTime You can pass a text date to the DateTime method
$date = \Thybag\SharepointApi::dateTime("2012-12-21");
Or Unix timestamp
$date = \Thybag\SharepointApi::dateTime(time(), true);
Problem finding
Unable to find wrapper "https"
If you get this error, it usually means that php_openssl (needed to curl https URLs) is not enabled on your web server. On many local web servers (such as XAMPP), you can simply open the php.ini file and uncomment the php_openssl line (i.e. delete; in front of it).
Note. If you are using SharePoint Online and are having SSL errors, install the latest version that has been changed from SSL v3 to TLS for SharePoint online connections.
Add this line to your composer.json file
thybag / php-sharepoint-lists-api: dev-develop
You can perform a CRUD operation (create / read / update / delete) using the above SharePoint API.
Link URL link: https://github.com/thybag/PHP-SharePoint-Lists-API