PHP code example of infiniityr / alfresco-php-api

1. Go to this page and download the library: Download infiniityr/alfresco-php-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

infiniityr / alfresco-php-api example snippets


$config = [
    'hostEcm' => 'http://localhost:8080',
    //'context' => 'alfresco',
    //'disableCsrf' => true
];
$alfrescoApi = new AlfrescoApi($config);

$alfrescoApi->login('login', 'password')->wait();

//Get all sites
$this->alfrescoApi->core->getSites()
    ->then(function(SitePaging $sites) {
        foreach ($sites->list->entries as $entry) {
            print_r(json_encode($entry) . "\n");
        }
    })->wait();

//Create a site
$siteBody = new SiteBody('Site Test PHP');
$siteBody->id = 'new_site_id';
$this->alfrescoApi->core->createSite($siteBody)
    ->then(function($data) {
        print_r("Site CREATED\n");
    })->wait();