PHP code example of gponty / entity-to-google-sheets-bundle

1. Go to this page and download the library: Download gponty/entity-to-google-sheets-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/ */

    

gponty / entity-to-google-sheets-bundle example snippets


return [
    // ...
    TonVendor\EntityToGoogleSheetsBundle\EntityToGoogleSheetsBundle::class => ['all' => true],
];

use Gponty\EntityToGoogleSheetsBundle\Attribute\SheetDescription;

#[SheetDescription('Représente un utilisateur de la plateforme')]
class User
{
    // ...
}

use Doctrine\ORM\Mapping as ORM;
use Gponty\EntityToGoogleSheetsBundle\Attribute\SheetDescription;

#[ORM\Entity]
#[SheetDescription('Représente un utilisateur de la plateforme')]
class User
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    #[SheetDescription('Identifiant unique de l\'utilisateur')]
    private ?int $id = null;

    #[ORM\Column(length: 180, unique: true)]
    #[SheetDescription('Adresse email utilisée pour la connexion')]
    private string $email;

    #[ORM\Column]
    #[SheetDescription('Date de création du compte')]
    private \DateTimeImmutable $createdAt;

    #[ORM\ManyToOne(targetEntity: Company::class)]
    #[SheetDescription('Entreprise à laquelle l\'utilisateur est rattaché')]
    private ?Company $company = null;
}

use Gponty\EntityToGoogleSheetsBundle\Service\EntityReader;
use Gponty\EntityToGoogleSheetsBundle\Service\GoogleSheetsExporter;

class MonService
{
    public function __construct(
        private readonly EntityReader $entityReader,
        private readonly GoogleSheetsExporter $exporter,
    ) {}

    public function faireQuelquechose()
    {
        $entities = $this->entityReader->getAllEntities();
        $this->exporter->export($entities);
    }
}
bash
php bin/console app:export-entities-to-sheets
bash
#!/bin/bash
# ... autres commandes de déploiement ...

# Étapes classiques
composer install --no-dev --optimize-autoloader
php bin/console doctrine:migrations:migrate --no-interaction
php bin/console cache:clear --env=prod

# ✨ Export automatique vers Google Sheets
php bin/console app:export-entities-to-sheets

echo "✓ Déploiement terminé !"
bash
# Vérifiez que le fichier credentials.json existe et est valide
# Vérifiez que le SPREADSHEET_ID est correct
# Vérifiez que le compte de service a accès au spreadsheet