PHPackages                             jsanga-des/php-sharepoint-graph-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. jsanga-des/php-sharepoint-graph-api

ActiveLibrary[API Development](/categories/api)

jsanga-des/php-sharepoint-graph-api
===================================

PHP Client for Microsoft Graph API - SharePoint Operations

2.0.3(8mo ago)013GPL-3.0-or-laterPHPPHP ^8.2

Since Aug 26Pushed 8mo agoCompare

[ Source](https://github.com/jsanga-des/PHP-Sharepoint-Graph-API)[ Packagist](https://packagist.org/packages/jsanga-des/php-sharepoint-graph-api)[ RSS](/packages/jsanga-des-php-sharepoint-graph-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (5)Used By (0)

Cliente SharePoint PHP
======================

[](#cliente-sharepoint-php)

Sencillo **cliente PHP** para interactuar con **SharePoint** Online a **través de Microsoft Graph API**. **Versión 2.0.2**

Descripción
-----------

[](#descripción)

Este cliente permite realizar operaciones básicas con SharePoint Online, incluyendo la gestión de archivos y carpetas a través de la API de Microsoft Graph. Soporta tres métodos de autenticación: Client Secret, Certificado PEM y PFX.

Características
---------------

[](#características)

- Autenticación con Microsoft Graph API
- Soporta múltiples entornos Sharepoint y configura cada uno de ellos, con sus respectivas credenciales.
- Múltiples métodos de autenticación: Client Secret, Certificado PEM y PFX
- Obtención de IDs de sitio y biblioteca
- Listado de archivos y carpetas
- Subida de archivos
- Eliminación de archivos
- Verificación de existencia de archivos y carpetas

Instalación con composer
------------------------

[](#instalación-con-composer)

Instalar la librería php-sharepoint-graph-api

```
composer require jsanga-des/php-sharepoint-graph-api:2.0.2
```

Incluir/disponer del autoloader

```
require_once __DIR__ . '/vendor/autoload.php';
```

> **Nota:** Este paquete está disponible en [Packagist](https://packagist.org/packages/jsanga-des/php-sharepoint-graph-api)

Ejecutar desde nuestro nuevo proyecto:

```
php vendor/jsanga-des/php-sharepoint-graph-api/scripts/setup.php
```

Alternativamente, se puede automatizar este paso agregando lo siguiente en el composer.json de tu proyecto principal:

```
"scripts": {
    "post-install-cmd": [
        "@setup-sharepoint"
    ],
    "post-update-cmd": [
        "@setup-sharepoint"
    ],
    "setup-sharepoint": [
        "php vendor/jsanga-des/php-sharepoint-graph-api/scripts/setup.php"
    ]
}
```

El comando anterior debe crearnos la siguiente estructura de carpetas:

```
mi-proyecto/
├── certs/
│   ├── (vacío) - Aquí debes incluri los certificados
├── examples/
│   ├── CheckCredentials.php
│   ├── DeleteFile.php
│   ├── FileExistsInFolder.php
│   ├── FolderExists.php
│   ├── ListFiles.php
│   ├── UploadFile.php
│   └── test_uploaded.txt
├── vendor/
│   └── ...
├── .env.sharepoint.example
├── composer.json
├── composer.lock
└── Sharepoint.php

```

Finalmente, crear el archivo .env en la raiz del proyecto.

> **Nota:** Fijarse en el archivo .env.sharepoint.example

Por lo que la estructura final será de la siguiente manera:

```
mi-proyecto/
├── certs/
│   ├── (vacío) - Aquí debes incluri los certificados
├── examples/
│   ├── CheckCredentials.php
│   ├── DeleteFile.php
│   ├── FileExistsInFolder.php
│   ├── FolderExists.php
│   ├── ListFiles.php
│   ├── UploadFile.php
│   └── test_uploaded.txt
├── vendor/
│   └── ...
├── .env.sharepoint.example
├── .env
├── composer.json
├── composer.lock
└── Sharepoint.php

```

Instalación Manual
------------------

[](#instalación-manual)

Clonar o descargar el repositorio:

```
git clone https://github.com/jsanga-des/php-sharepoint-graph-api.git
```

Ejecutar desde nuestro nuevo proyecto:

```
php vendor/jsanga-des/php-sharepoint-graph-api/scripts/setup.php
```

Alternativamente, se puede automatizar este paso agregando lo siguiente en el composer.json de tu proyecto principal:

```
"scripts": {
    "post-install-cmd": [
        "@setup-sharepoint"
    ],
    "post-update-cmd": [
        "@setup-sharepoint"
    ],
    "setup-sharepoint": [
        "php vendor/jsanga-des/php-sharepoint-graph-api/scripts/setup.php"
    ]
}
```

El comando anterior debe crearnos la siguiente estructura de carpetas:

```
mi-proyecto/
├── certs/
│   ├── (vacío) - Aquí debes incluri los certificados
├── examples/
│   ├── CheckCredentials.php
│   ├── DeleteFile.php
│   ├── FileExistsInFolder.php
│   ├── FolderExists.php
│   ├── ListFiles.php
│   ├── UploadFile.php
│   └── test_uploaded.txt
├── vendor/
│   └── ...
├── .env.sharepoint.example
├── composer.json
├── composer.lock
└── Sharepoint.php

```

Finalmente, crear el archivo .env en la raiz del proyecto.

> **Nota:** Fijarse en el archivo .env.sharepoint.example

Por lo que la estructura final será de la siguiente manera:

```
mi-proyecto/
├── certs/
│   ├── (vacío) - Aquí debes incluri los certificados
├── examples/
│   ├── CheckCredentials.php
│   ├── DeleteFile.php
│   ├── FileExistsInFolder.php
│   ├── FolderExists.php
│   ├── ListFiles.php
│   ├── UploadFile.php
│   └── test_uploaded.txt
├── vendor/
│   └── ...
├── .env.sharepoint.example
├── .env
├── composer.json
├── composer.lock
└── Sharepoint.php

```

Inicialización del cliente:
---------------------------

[](#inicialización-del-cliente)

```
use SharepointClient\SharepointClient;
use SharepointClient\Config\ConfigManager;

// Cargar configuración por nombre de entorno
$config = ConfigManager::getInstance('default');
// O Alternativamente: $config = ConfigManager::getInstance('entorno1');

// Crear el cliente
$client = new SharepointClient($config);
```

Configuración de entornos:
--------------------------

[](#configuración-de-entornos)

El cliente utiliza un sistema de entornos definido en el archivo ./Sharepoint.php. Cada sitio o instancia de SharePoint se configura aquí con sus credenciales, método de autenticación y valores generales de ejecución. Es importante no exponer aquí las credenciales. Aquí sólo se debe nombrar la variable de entorno que contiene el valor secreto.

```
return [
    'env' => [
        'debug' => true,
        'log_level' => 'DEBUG',
        'timeout' => 120,
        'connect_timeout' => 60,
    ],
    'sites' => [
        'default' => [
            'general' => [
                'client_id' => getenv('SHAREPOINT_ENTORNO1_CLIENT_ID'),
                'tenant_id' => getenv('SHAREPOINT_ENTORNO1_TENANT_ID'),
                'site_path' => getenv('SHAREPOINT_ENTORNO1_SITE_PATH'),
                'default_library' => getenv('SHAREPOINT_ENTORNO1_DEFAULT_LIBRARY'),
            ],
            'auth_method' => getenv('SHAREPOINT_ENTORNO1_AUTH_METHOD') ?? 'client_secret',
            'auth' => [
                'client_secret' => [
                    'secret' => getenv('SHAREPOINT_ENTORNO1_CLIENT_SECRET'),
                ],
                'certificate_pfx' => [
                    'path' => getenv('SHAREPOINT_ENTORNO1_PFX_PATH'),
                    'passphrase' => getenv('SHAREPOINT_ENTORNO1_PFX_PASSPHRASE'),
                ],
                'certificate_crt' => [
                    'cert_path' => getenv('SHAREPOINT_ENTORNO1_CERT_PATH'),
                    'key_path' => getenv('SHAREPOINT_ENTORNO1_KEY_PATH'),
                    'passphrase' => getenv('SHAREPOINT_ENTORNO1_KEY_PASSPHRASE'),
                ],
            ],
        ],
        // Otros entornos 'entorno2', 'entorno3', etc, con sus respectivas credenciales.
    ],
];
```

> **Nota:** Puedes definir tantos entornos en `sites` como desees.

Variables de entorno
--------------------

[](#variables-de-entorno)

Ejemplo para el archivo .env

```
SHAREPOINT_EMPRESA_A_CLIENT_ID=xxxx-xxxx-xxxx-xxxx
SHAREPOINT_EMPRESA_A_TENANT_ID=yyyy-yyyy-yyyy-yyyy
SHAREPOINT_EMPRESA_A_SITE_PATH=miempresa.sharepoint.com:/sites/MiSitio
SHAREPOINT_EMPRESA_A_DEFAULT_LIBRARY=Documentos
SHAREPOINT_EMPRESA_A_AUTH_METHOD=client_secret
SHAREPOINT_EMPRESA_A_CLIENT_SECRET=mi-secret
SHAREPOINT_EMPRESA_A_PFX_PATH=certificados/mi-certificado.pfx
SHAREPOINT_EMPRESA_A_PFX_PASSPHRASE=mi-password
SHAREPOINT_EMPRESA_A_CERT_PATH=certificados/mi-certificado.crt
SHAREPOINT_EMPRESA_A_KEY_PATH=certificados/private.key
SHAREPOINT_EMPRESA_A_KEY_PASSPHRASE=mi-key-password

SHAREPOINT_EMPRESA_B_CLIENT_ID=xxxx-xxxx-xxxx-xxxx
SHAREPOINT_EMPRESA_B_TENANT_ID=yyyy-yyyy-yyyy-yyyy
SHAREPOINT_EMPRESA_B_SITE_PATH=miempresa.sharepoint.com:/sites/MiSitio
SHAREPOINT_EMPRESA_B_DEFAULT_LIBRARY=Documentos
SHAREPOINT_EMPRESA_B_AUTH_METHOD=client_secret
SHAREPOINT_EMPRESA_B_CLIENT_SECRET=mi-secret
SHAREPOINT_EMPRESA_B_PFX_PATH=certificados/mi-certificado.pfx
SHAREPOINT_EMPRESA_B_PFX_PASSPHRASE=mi-password
SHAREPOINT_EMPRESA_B_CERT_PATH=certificados/mi-certificado.crt
SHAREPOINT_EMPRESA_B_KEY_PATH=certificados/private.key
SHAREPOINT_EMPRESA_B_KEY_PASSPHRASE=mi-key-password

SHAREPOINT_OTRO_ENTORNO_CLIENT_ID=xxxx-xxxx-xxxx-xxxx
SHAREPOINT_OTRO_ENTORNO_TENANT_ID=yyyy-yyyy-yyyy-yyyy
SHAREPOINT_OTRO_ENTORNO_SITE_PATH=miempresa.sharepoint.com:/sites/MiSitio
SHAREPOINT_OTRO_ENTORNO_DEFAULT_LIBRARY=Documentos
SHAREPOINT_OTRO_ENTORNO_AUTH_METHOD=client_secret
SHAREPOINT_OTRO_ENTORNO_CLIENT_SECRET=mi-secret
SHAREPOINT_OTRO_ENTORNO_PFX_PATH=certificados/mi-certificado.pfx
SHAREPOINT_OTRO_ENTORNO_PFX_PASSPHRASE=mi-password
SHAREPOINT_OTRO_ENTORNO_CERT_PATH=certificados/mi-certificado.crt
SHAREPOINT_OTRO_ENTORNO_KEY_PATH=certificados/private.key
SHAREPOINT_OTRO_ENTORNO_KEY_PASSPHRASE=mi-key-password
```

> **Nota:** Puedes definir varios entornos (./Sharepoint.php) y referenciar qué variables de entorno deben emplear esos entornos. Lo siguiente será incluir esas variables de entorno en tu servidor, y podrás cargar la configuración correspondiente con ConfigManager::getInstance('otro\_entorno').

Requisitos previos
------------------

[](#requisitos-previos)

### Dependencias del proyecto

[](#dependencias-del-proyecto)

- **PHP**: &gt;= 8.2
- **Extensiones PHP requeridas**:
    - ext-curl
    - ext-json
- **Dependencias Composer**:
    - firebase/php-jwt: ^6.11

### Autenticación mediante CLIENT\_SECRET

[](#autenticación-mediante-client_secret)

VariableDescripción`CLIENT_ID`ID de aplicación (cliente) - Identificador único de tu aplicación registrada`TENANT_ID`ID de inquilino (tenant) - Identificador de tu organización en Azure AD`CLIENT_SECRET`Valor del secreto de cliente - El valor secreto generado en Azure AD### Autenticación mediante certificado PFX

[](#autenticación-mediante-certificado-pfx)

VariableDescripción`CLIENT_ID`ID de aplicación (cliente) - Identificador único de tu aplicación registrada`TENANT_ID`ID de inquilino (tenant) - Identificador de tu organización en Azure AD`PFX_FILE_PATH`Certificado en formato PFX/PKCS12`PFX_FILE_PASSWORD`Password para poder emplear el certificado### Autenticación mediante certificado PEM

[](#autenticación-mediante-certificado-pem)

VariableDescripción`CLIENT_ID`ID de aplicación (cliente) - Identificador único de tu aplicación registrada`TENANT_ID`ID de inquilino (tenant) - Identificador de tu organización en Azure AD`PEM_FILE_PATH`Certificado en formato PEM`PEM_FILE_KEY`Archivo de clave privada### Ejemplos de uso

[](#ejemplos-de-uso)

```
/ejemplos
├── TestDeleteFile.php
├── TestDeleteFileBySitePath.php
├── TestFileExistsInFolder.php
├── TestFolderExists.php
├── TestListFiles.php
├── TestListFilesBySitePath.php
├── TestUploadFile.php
└── TestUploadFileBySitePath.php

```

#### Operaciones básicas con archivos

[](#operaciones-básicas-con-archivos)

- [TestUploadFile.php](ejemplos/TestUploadFile.php) → Subir un archivo
- [TestListFiles.php](ejemplos/TestListFiles.php) → Listar archivos
- [TestFileExistsInFolder.php](ejemplos/TestFileExistsInFolder.php) → Verificar si existe un archivo
- [TestDeleteFile.php](ejemplos/TestDeleteFile.php) → Eliminar un archivo

#### Operaciones con rutas específicas del sitio

[](#operaciones-con-rutas-específicas-del-sitio)

- [TestUploadFileBySitePath.php](ejemplos/TestUploadFileBySitePath.php) → Subir archivo usando ruta del sitio
- [TestListFilesBySitePath.php](ejemplos/TestListFilesBySitePath.php) → Listar archivos por ruta del sitio
- [TestDeleteFileBySitePath.php](ejemplos/TestDeleteFileBySitePath.php) → Eliminar archivo por ruta del sitio

#### Operaciones con carpetas

[](#operaciones-con-carpetas)

- [TestFolderExists.php](ejemplos/TestFolderExists.php) → Verificar si existe una carpeta

Documentación adicional
-----------------------

[](#documentación-adicional)

- [Microsoft Graph API Documentation](https://docs.microsoft.com/en-us/graph/)
- [SharePoint REST API Reference](https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/complete-basic-operations-using-sharepoint-rest-endpoints)

Contribuciones
--------------

[](#contribuciones)

Las contribuciones son bienvenidas. Por favor, abre un issue o envía un pull request.

Licencia
--------

[](#licencia)

GNU General Public License v3.0

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance59

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

262d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4beebc3fc63b16947b6173d724d96c4a188a5112b42bbecbfb14dd10bbb8155d?d=identicon)[jsanga-des](/maintainers/jsanga-des)

---

Top Contributors

[![jsanga-des](https://avatars.githubusercontent.com/u/127992936?v=4)](https://github.com/jsanga-des "jsanga-des (14 commits)")

---

Tags

phpapi clientOffice365sharepointMicrosoft graph

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jsanga-des-php-sharepoint-graph-api/health.svg)

```
[![Health](https://phpackages.com/badges/jsanga-des-php-sharepoint-graph-api/health.svg)](https://phpackages.com/packages/jsanga-des-php-sharepoint-graph-api)
```

###  Alternatives

[docusign/esign-client

The Docusign PHP library makes integrating Docusign into your apps and websites a super fast and painless process. The library is open sourced on GitHub, look for the docusign-esign-php-client repository. Join the eSign revolution!

2087.4M13](/packages/docusign-esign-client)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[phplicengine/bitly

Bitly API v4

22277.3k](/packages/phplicengine-bitly)[fabian-beiner/todoist-php-api-library

A PHP client library that provides a native interface to the official Todoist REST API.

4810.8k](/packages/fabian-beiner-todoist-php-api-library)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
