PHP code example of jeffersongoncalves / laravel-webflow

1. Go to this page and download the library: Download jeffersongoncalves/laravel-webflow 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/ */

    

jeffersongoncalves / laravel-webflow example snippets


return [
    'token' => env('WEBFLOW_API_TOKEN'),
    'base_url' => env('WEBFLOW_BASE_URL', 'https://api.webflow.com/v2'),
];

use Jeffersongoncalves\Webflow\Facades\Webflow;

$sites = Webflow::listSites();

$site = Webflow::getSite('siteId');

Webflow::publishSite('siteId', customDomains: ['www.example.com'], publishToWebflowSubdomain: true);

$collections = Webflow::listCollections('siteId');

$items = Webflow::listCollectionItems('collectionId', limit: 10, offset: 0);

$item = Webflow::getCollectionItem('collectionId', 'itemId');

Webflow::createCollectionItem('collectionId', fieldData: [
    'name' => 'My New Item',
    'slug' => 'my-new-item',
], isDraft: true);

Webflow::updateCollectionItem('collectionId', 'itemId', fieldData: [
    'name' => 'Updated Item',
]);

Webflow::publishCollectionItems('collectionId', ['itemId1', 'itemId2']);

$forms = Webflow::listForms('siteId');

$submissions = Webflow::listFormSubmissions('formId', limit: 25, offset: 0);

use Jeffersongoncalves\Webflow\Exceptions\WebflowException;

try {
    Webflow::publishSite('siteId');
} catch (WebflowException $e) {
    logger()->error($e->getMessage(), $e->errorBody());
}
bash
php artisan vendor:publish --tag="laravel-webflow-config"