Download the PHP package prasadchinwal/microsoft-graph without Composer

On this page you can find all versions of the php package prasadchinwal/microsoft-graph. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package microsoft-graph

Laravel Microsoft Graph

Latest Version on Packagist Total Downloads License

A comprehensive Laravel wrapper for Microsoft Graph API that provides an elegant, fluent interface for interacting with Microsoft 365 services including users, calendars, events, mail, and more.

Features

Requirements

Installation

Install the package via Composer:

Publish the configuration file:

This will create a config/microsoft-graph.php file in your application.

Configuration

1. Azure App Registration

Before using this package, you need to register an application in the Azure Portal:

  1. Navigate to Azure Active Directory > App registrations
  2. Click New registration
  3. Give your app a name and select supported account types
  4. Click Register
  5. Note down the Application (client) ID and Directory (tenant) ID
  6. Go to Certificates & secrets > New client secret
  7. Create a new secret and note down its value
  8. Go to API permissions and add the required Microsoft Graph permissions:
    • User.Read.All
    • User.ReadWrite.All
    • Calendars.Read
    • Calendars.ReadWrite
    • Mail.Read
    • Mail.Send
    • Grant admin consent for your organization

2. Environment Configuration

Add the following to your .env file:

3. Configuration File

The config/microsoft-graph.php file contains:

Note: The package will validate configuration on boot and throw a ConfigurationException if required values are missing.

Usage

Initialization

The package can be used via the Facade or by instantiating the class:


User Management

Get All Users

Retrieve all users in your organization.

API Reference: List Users

Get a Specific User

Retrieve a user by their email address (User Principal Name).

API Reference: Get User

Update a User

Update user properties using the User builder.

API Reference: Update User

Get User Licenses

Retrieve license details for a user.

API Reference: List License Details

Assign License to User

Assign one or more licenses to a user.

API Reference: Assign License


Profile Photos

Get User Profile Photo

Download a user's profile photo.

API Reference: Get Photo

Update User Profile Photo

Upload a new profile photo for a user.

API Reference: Update Photo

Delete User Profile Photo

Remove a user's profile photo.

API Reference: Delete Photo


Calendar Management

Get User Calendars

Retrieve all calendars for a user.

API Reference: List Calendars

Get User Schedule

Get free/busy schedule information for one or more users.

API Reference: Get Schedule

Get Calendar View

Get calendar events within a specific time range.

API Reference: List Calendar View


Event Management

Get User Events

Retrieve calendar events for a user.

API Reference: List Events

Filter Events

Use OData filters to query specific events.

API Reference: Filter Query Parameter

Create an Event

Create a new calendar event using a CalendarEvent class.

API Reference: Create Event

Step 1: Generate an event class:

Step 2: Configure the event class:

Step 3: Create the event:

Update an Event

Update an existing calendar event.

API Reference: Update Event

Accept an Event

Accept a meeting invitation.

API Reference: Accept Event

Decline an Event

Decline a meeting invitation.

API Reference: Decline Event

Cancel an Event

Cancel a meeting (organizer only).

API Reference: Cancel Event


Mail Management

Get User Messages

Retrieve email messages for a user.

API Reference: List Messages

Filter Messages

Apply OData filters to retrieve specific messages.


Sending Email

Send Email via Outlook

Send an email on behalf of a user.

API Reference: Send Mail


Team Configuration

Get User Team Configuration

API Reference: User Team Configuration

Helper Methods

Check is users Enterprise Voice is enabled:


Number Assignments

List numberAssignments

API Reference: List numberAssignments


Attachment Management

Microsoft Graph API supports three types of attachments:

List Attachments

Get all attachments for a message or event.

API Reference: List Attachments

Get Attachment Metadata

Retrieve metadata for a specific attachment.

API Reference: Get Attachment

Download Attachment Content

Download the raw binary content of a file attachment.

Add File Attachment

Upload a file attachment (up to 3MB).

API Reference: Add Attachment

From File Path:

From Binary Data:

Inline Attachment (for emails):

Add Reference Attachment

Add a link to a file stored on OneDrive, Dropbox, or other cloud storage.

Available Providers:

Available Permissions:

Add Custom Attachment

Add an attachment using custom array data for advanced scenarios.

Delete Attachment

Remove an attachment from a message or event.

API Reference: Delete Attachment

Complete Example: Sending Email with Attachments

Size Limitations

Important: The direct attachment API supports files up to 3MB. For larger files (3-150MB), use the upload session method:

Attachment Types Reference

Type Use Case Max Size Properties
fileAttachment Documents, images, files 3 MB contentBytes, contentType, name
itemAttachment Embedded contacts, events, messages 3 MB item (nested object)
referenceAttachment OneDrive, SharePoint, Dropbox links N/A sourceUrl, providerType, permission

Error Handling

The package includes custom exceptions for better error handling:

Exception Classes

Example Usage

Configuration Validation

The package automatically validates configuration on boot:


Advanced Features

Token Caching

Access tokens are automatically cached with a 5-minute buffer before expiry. This significantly improves performance by preventing redundant OAuth requests.

To manually clear the token cache (useful for testing):

Custom Timezone

Set a custom timezone for calendar operations in your .env:

Or directly in the config file:

Data Transfer Objects

All responses are returned as strongly-typed Spatie Data objects:


Testing

The package includes factories and helpers for testing. You can mock the Microsoft Graph API in your tests:


Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Security

If you discover any security-related issues, please email the package author instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Support

For support, please open an issue on GitHub or contact the maintainer.

Links


All versions of microsoft-graph with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2|^8.3|^8.4|^8.5
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
spatie/laravel-data Version ^4.11
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package prasadchinwal/microsoft-graph contains the following files

Loading the files please wait ...