PHP code example of republique-et-canton-de-geneve / php-symfony-data-content-bundle

1. Go to this page and download the library: Download republique-et-canton-de-geneve/php-symfony-data-content-bundle 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/ */

    

republique-et-canton-de-geneve / php-symfony-data-content-bundle example snippets


use EtatGeneve\DataContentBundle\Service\DataContent;

// Inject the DataContent service
public function __construct(
    private DataContent $dataContent,
) {
}

// Search documents
$results = $this->dataContent->searchByQuery(
    'DOCUMENT_TYPE:quotidienne',
    ['pageSize' => 100, 'searchLimit' => 1000],
    30
);

// Get document metadata by UUID
$metadata = $this->dataContent->searchByUuid('document-uuid-123');

// Download document content as binary string
$content = $this->dataContent->getDocument('document-uuid-123', httpResponse: false);

// Download document with Symfony Response (headers + download)
$response = $this->dataContent->getDocument('document-uuid-123', httpResponse: true);

// Store a new document
$this->dataContent->storeDocument(
    '/path/to/file.pdf',
    title: 'My Document',
    criterions: [
        ['categoryName' => 'METIER_DATE', 'wordValue' => '20231124', 'wordType' => 'String']
    ],
    options: ['filename' => 'my-file.pdf', 'extension' => 'pdf', 'documentType' => '10A_SUPPRESSION']
);

// Delete a document
$this->dataContent->deleteDocument('document-uuid-123');