PHPackages                             codebar-ag/laravel-m-files - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. codebar-ag/laravel-m-files

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

codebar-ag/laravel-m-files
==========================

M-Files integration with Laravel

v13.0(6mo ago)05.1k[1 PRs](https://github.com/codebar-ag/laravel-m-files/pulls)MITPHPPHP 8.4.\*CI failing

Since Aug 2Pushed 1mo agoCompare

[ Source](https://github.com/codebar-ag/laravel-m-files)[ Packagist](https://packagist.org/packages/codebar-ag/laravel-m-files)[ Docs](https://github.com/codebar-ag/laravel-m-files)[ RSS](/packages/codebar-ag-laravel-m-files/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (15)Versions (22)Used By (0)

[![Laravel M-Files banner with description and logo](https://camo.githubusercontent.com/5897f4ec76b49c51a28e00dce2f9a7fa74dc56712027b73b616b15c038249b4b/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c2532304d2d46696c65732e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d636f64656261722d61672532466c61726176656c2d6d2d66696c6573267061747465726e3d63697263756974426f617264267374796c653d7374796c655f31266465736372697074696f6e3d416e2b6f70696e696f6e617465642b7761792b746f2b696e746567726174652b4d2d46696c65732b776974682b4c61726176656c266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313735707826696d616765733d646f63756d656e742d7265706f7274)](https://camo.githubusercontent.com/5897f4ec76b49c51a28e00dce2f9a7fa74dc56712027b73b616b15c038249b4b/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c2532304d2d46696c65732e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d636f64656261722d61672532466c61726176656c2d6d2d66696c6573267061747465726e3d63697263756974426f617264267374796c653d7374796c655f31266465736372697074696f6e3d416e2b6f70696e696f6e617465642b7761792b746f2b696e746567726174652b4d2d46696c65732b776974682b4c61726176656c266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313735707826696d616765733d646f63756d656e742d7265706f7274)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d04b959db3ff04e41c26fa906d5c277c69caa093e9dbf83441ec276d6348f8b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f64656261722d61672f6c61726176656c2d6d2d66696c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codebar-ag/laravel-m-files)[![GitHub-Tests](https://github.com/codebar-ag/laravel-m-files/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-m-files/actions/workflows/run-tests.yml)[![GitHub Code Style](https://github.com/codebar-ag/laravel-m-files/actions/workflows/fix-php-code-style-issues.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-m-files/actions/workflows/fix-php-code-style-issues.yml)[![Larastan](https://camo.githubusercontent.com/b6156838f622c5fb8df1ff4ba300a3424e99d61db1b1d9784afdbf8f62cd6a94/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6172617374616e2d4c6576656c253230352d627269676874677265656e2e737667)](https://github.com/larastan/larastan)[![Total Downloads](https://camo.githubusercontent.com/9200794d0dc4370c3c5ab77b315d135896ae8a88b0908b4189b69b88681aa0be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f64656261722d61672f6c61726176656c2d6d2d66696c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codebar-ag/laravel-m-files)

Laravel M-Files Integration
===========================

[](#laravel-m-files-integration)

A Laravel package providing DTOs and requests for integrating with M-Files REST API.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require codebar-ag/laravel-m-files
```

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="CodebarAg\MFiles\MFilesServiceProvider"
```

Add your M-Files authentication credentials to your `.env` file:

```
M_FILES_URL=https://your-mfiles-server.com
M_FILES_USERNAME=your-username
M_FILES_PASSWORD=your-password
M_FILES_VAULT_GUID=ABC0DE2G-3HW-QWCQ-SDF3-WERWETWETW
M_FILES_CACHE_DRIVER=file
```

### Configuration Options

[](#configuration-options)

The package supports the following configuration options:

- `M_FILES_URL` - Your M-Files server URL
- `M_FILES_USERNAME` - Your M-Files username
- `M_FILES_PASSWORD` - Your M-Files password
- `M_FILES_VAULT_GUID` - The vault GUID to connect to
- `M_FILES_CACHE_DRIVER` - Cache driver for storing authentication tokens (default: file)

Authentication
--------------

[](#authentication)

The package provides automatic authentication token management with caching support.

### M-Files Connector

[](#m-files-connector)

```
use CodebarAg\MFiles\Connectors\MFilesConnector;
use CodebarAg\MFiles\DTO\ConfigWithCredentials;

$config = new ConfigWithCredentials(
    url: 'https://your-mfiles-server.com',
    vaultGuid: '{ABC0DE2G-3HW-QWCQ-SDF3-WERWETWETW}',
    username: 'your-username',
    password: 'your-password',
    cacheDriver: 'file'
);

$connector = new MFilesConnector(config: $config);
```

### Authentication

[](#authentication-1)

Authentication is handled automatically by the `MFilesConnector`. When you create a connector instance with your credentials, it will automatically:

1. **Cache authentication tokens** - Tokens are cached for 1 hour to avoid repeated login requests
2. **Include authentication headers** - The `X-Authentication` header is automatically added to all requests
3. **Handle token refresh** - When tokens expire, new ones are automatically obtained

```
use CodebarAg\MFiles\Requests\LogInToVaultRequest;

// Manual authentication (if needed)
$request = new LogInToVaultRequest(
    url: 'https://your-mfiles-server.com',
    vaultGuid: '{ABC0DE2G-3HW-QWCQ-SDF3-WERWETWETW}',
    username: 'your-username',
    password: 'your-password',
);

$token = $request->send()->dto();
// Returns authentication token as string
```

Requests
--------

[](#requests)

### Authentication Requests

[](#authentication-requests)

#### LogInToVaultRequest

[](#logintovaultrequest)

Gets an authentication token using username/password credentials.

**Constructor Parameters:**

- `url` (string) - M-Files server URL
- `vaultGuid` (string) - Vault GUID
- `username` (string) - M-Files username
- `password` (string) - M-Files password

**Request:**

```
use CodebarAg\MFiles\Requests\LogInToVaultRequest;

$request = new LogInToVaultRequest(
    url: 'https://your-mfiles-server.com',
    vaultGuid: '{ABC0DE2G-3HW-QWCQ-SDF3-WERWETWETW}',
    username: 'your-username',
    password: 'your-password',
);
```

**Response:**

```
$token = $request->send()->dto();
// Returns authentication token as string
```

### File Requests

[](#file-requests)

#### UploadFileRequest

[](#uploadfilerequest)

Uploads a file to M-Files.

**Constructor Parameters:**

- `fileContent` (string) - File content
- `fileName` (string) - File name

**Request:**

```
use CodebarAg\MFiles\Requests\UploadFileRequest;

$request = new UploadFileRequest(
    fileContent: $fileContent,
    fileName: 'document.pdf'
);
```

**Response:**

```
$uploadedFile = $connector->send($request)->dto();
// Returns array with file information including Title, Extension, and other metadata
```

#### CreateSingleFileDocumentRequest

[](#createsinglefiledocumentrequest)

Creates a single file document in M-Files.

**Constructor Parameters:**

- `title` (string) - Document title
- `files` (array) - Array of uploaded file information
- `propertyValues` (array) - Array of SetProperty objects for custom properties

**Request:**

```
use CodebarAg\MFiles\Requests\CreateSingleFileDocumentRequest;
use CodebarAg\MFiles\DTO\SetProperty;
use CodebarAg\MFiles\Enums\MFDataTypeEnum;

$request = new CreateSingleFileDocumentRequest(
    title: 'My Document',
    files: [$uploadedFile]
);
```

**Response:**

```
use CodebarAg\MFiles\DTO\ObjectProperties;

$document = $connector->send($request)->dto();
// Returns ObjectProperties DTO with document information
```

**With Custom Property Values:**

```
$propertyValues = [
    new SetProperty(propertyDef: 0, dataType: MFDataTypeEnum::TEXT, value: 'Custom Title'),
    new SetProperty(propertyDef: 5, dataType: MFDataTypeEnum::DATE, value: '2024-01-01'),
];

$request = new CreateSingleFileDocumentRequest(
    title: 'Custom Document',
    files: [$uploadedFile],
    propertyValues: $propertyValues
);
```

#### DownloadFileRequest

[](#downloadfilerequest)

Downloads a file from M-Files.

**Constructor Parameters:**

- `objectType` (int) - Object type ID
- `objectId` (int) - Object ID
- `objectVersion` (int) - Object version
- `fileId` (int) - File ID

**Request:**

```
use CodebarAg\MFiles\Requests\DownloadFileRequest;

$request = new DownloadFileRequest(
    objectType: 0,
    objectId: 123,
    objectVersion: 1,
    fileId: 456
);
```

**Response:**

```
use CodebarAg\MFiles\DTO\DownloadedFile;

$downloadedFile = $connector->send($request)->dto();
// Returns DownloadedFile DTO with content, name, extension, size, contentType
```

### Property Requests

[](#property-requests)

#### GetObjectInformationRequest

[](#getobjectinformationrequest)

Retrieves object information and properties from M-Files.

**Constructor Parameters:**

- `objectType` (int) - Object type ID
- `objectId` (int) - Object ID
- `objectVersion` (int) - Object version

**Request:**

```
use CodebarAg\MFiles\Requests\GetObjectInformationRequest;

$request = new GetObjectInformationRequest(
    objectType: 0,
    objectId: 123,
    objectVersion: 1
);
```

**Response:**

```
use CodebarAg\MFiles\DTO\ObjectProperties;

$objectProperties = $connector->send($request)->dto();
// Returns ObjectProperties DTO with object information and properties
```

#### SetPropertiesRequest

[](#setpropertiesrequest)

Sets properties for an existing object in M-Files.

**Constructor Parameters:**

- `objectType` (int) - Object type ID
- `objectId` (int) - Object ID
- `objectVersion` (int) - Object version (-1 for latest)
- `propertyValues` (array) - Array of SetProperty objects

**Request:**

```
use CodebarAg\MFiles\Requests\SetPropertiesRequest;
use CodebarAg\MFiles\DTO\SetProperty;
use CodebarAg\MFiles\Enums\MFDataTypeEnum;

$propertyValues = [
    new SetProperty(1856, MFDataTypeEnum::BOOLEAN, true),
    new SetProperty(0, MFDataTypeEnum::TEXT, 'Updated Title'),
];

$request = new SetPropertiesRequest(
    objectType: 140,
    objectId: 1770,
    objectVersion: -1,
    propertyValues: $propertyValues
);
```

**Response:**

```
use CodebarAg\MFiles\DTO\ObjectProperties;

$objectProperties = $connector->send($request)->dto();
// Returns ObjectProperties DTO with updated object information
```

DTOs
----

[](#dtos)

### Configuration DTOs

[](#configuration-dtos)

#### ConfigWithCredentials

[](#configwithcredentials)

Represents M-Files configuration with authentication credentials.

**Properties:**

- `url` (string) - M-Files server URL
- `vaultGuid` (string) - Vault GUID
- `username` (string) - M-Files username
- `password` (string) - M-Files password
- `cacheDriver` (string|null) - Cache driver for tokens

**Methods:**

- `fromArray(array $data): self` - Static factory method
- `toArray(): array` - Converts to array format

**Usage:**

```
use CodebarAg\MFiles\DTO\ConfigWithCredentials;

$config = new ConfigWithCredentials(
    url: 'https://your-mfiles-server.com',
    username: 'your-username',
    password: 'your-password',
    vaultGuid: '{ABC0DE2G-3HW-QWCQ-SDF3-WERWETWETW}',
    cacheDriver: 'file'
);

// Using static factory method
$config = ConfigWithCredentials::fromArray([
    'url' => 'https://your-mfiles-server.com',
    'username' => 'your-username',
    'password' => 'your-password',
    'vaultGuid' => '{ABC0DE2G-3HW-QWCQ-SDF3-WERWETWETW}',
    'cacheDriver' => 'file'
]);
```

### File DTOs

[](#file-dtos)

#### File

[](#file)

Represents a file in M-Files.

**Properties:**

- `id` (int) - File ID
- `name` (string) - File name
- `extension` (string|null) - File extension
- `version` (int|null) - File version
- `size` (int|null) - File size in bytes

**Methods:**

- `fromArray(array $data): self` - Static factory method
- `toArray(): array` - Converts to array format

**Usage:**

```
use CodebarAg\MFiles\DTO\File;

$file = new File(
    id: 456,
    name: 'document.pdf',
    extension: 'pdf',
    version: 1,
    size: 1024
);

// Using static factory method
$file = File::fromArray([
    'ID' => 456,
    'Name' => 'document.pdf',
    'Extension' => 'pdf',
    'Version' => 1,
    'Size' => 1024
]);
```

#### DownloadedFile

[](#downloadedfile)

Represents a downloaded file with content and metadata.

**Properties:**

- `name` (string|null) - File name
- `extension` (string|null) - File extension
- `size` (int|null) - File size in bytes
- `contentType` (string|null) - MIME content type
- `content` (string) - File content

**Methods:**

- `fromArray(array $data): self` - Static factory method
- `toArray(): array` - Converts to array format

**Usage:**

```
use CodebarAg\MFiles\DTO\DownloadedFile;

$downloadedFile = new DownloadedFile(
    name: 'document.pdf',
    extension: 'pdf',
    size: 1024,
    contentType: 'application/pdf',
    content: $fileContent
);

// Using static factory method
$downloadedFile = DownloadedFile::fromArray([
    'name' => 'document.pdf',
    'extension' => 'pdf',
    'size' => 1024,
    'contentType' => 'application/pdf',
    'content' => $fileContent
]);
```

### Property DTOs

[](#property-dtos)

#### SetProperty

[](#setproperty)

Represents a property value for creating documents.

**Properties:**

- `propertyDef` (int) - Property definition ID
- `dataType` (MFDataTypeEnum) - Property data type
- `value` (mixed) - Property value
- `displayValue` (mixed) - Display value (optional)

**Methods:**

- `fromArray(int $propertyDef, MFDataTypeEnum $dataType, mixed $value, mixed $displayValue = null): self` - Static factory method
- `toArray(): array` - Converts to array format for API requests

**Usage:**

```
use CodebarAg\MFiles\DTO\SetProperty;
use CodebarAg\MFiles\Enums\MFDataTypeEnum;

$propertyValue = new SetProperty(
    propertyDef: 0,
    dataType: MFDataTypeEnum::TEXT,
    value: 'Sample Text'
);

// Using static factory method
$propertyValue = SetProperty::fromArray(
    propertyDef: 0,
    dataType: MFDataTypeEnum::TEXT,
    value: 'Sample Text'
);

// Convert to array for API requests
$array = $propertyValue->toArray();
```

#### GetProperty

[](#getproperty)

Represents a property retrieved from M-Files.

**Properties:**

- `propertyDef` (int) - Property definition ID
- `dataType` (MFDataTypeEnum) - Property data type
- `value` (mixed) - Property value
- `displayValue` (mixed) - Display value

**Methods:**

- `fromArray(array $data): self` - Static factory method
- `toArray(): array` - Converts to array format

**Usage:**

```
use CodebarAg\MFiles\DTO\GetProperty;

$property = GetProperty::fromArray([
    'PropertyDef' => 0,
    'Value' => [
        'DataType' => 1,
        'Value' => 'Sample Text',
        'DisplayValue' => 'Sample Text'
    ]
]);
```

#### ObjectProperties

[](#objectproperties)

Represents object properties in M-Files.

**Properties:**

- `classId` (int) - Class ID
- `objectId` (int) - Object ID
- `objectTypeId` (int) - Object type ID
- `objectVersionId` (int) - Object version ID
- `lastModifiedAt` (CarbonImmutable) - Last modified timestamp
- `properties` (Collection) - Collection of GetProperty objects
- `files` (Collection) - Collection of File objects

**Methods:**

- `fromArray(array $data): self` - Static factory method
- `toArray(): array` - Converts to array format

**Usage:**

```
use CodebarAg\MFiles\DTO\ObjectProperties;

$objectProperties = ObjectProperties::fromArray([
    'Class' => 1,
    'ObjVer' => [
        'ID' => 123,
        'Type' => 0,
        'Version' => 1,
        'Modified' => '2024-01-01T00:00:00Z'
    ],
    'Properties' => [],
    'Files' => []
]);
```

### Enums

[](#enums)

#### MFDataTypeEnum

[](#mfdatatypeenum)

Represents data types in M-Files.

**Available Values:**

- `UNINITIALIZED` (0) - Document/Object
- `TEXT` (1) - Text
- `INTEGER` (2) - A 32-bit integer
- `FLOATING` (3) - A double-precision floating point
- `DATE` (5) - Date
- `TIME` (6) - Time
- `TIMESTAMP` (7) - Timestamp
- `BOOLEAN` (8) - Boolean
- `LOOKUP` (9) - Lookup (from a value list)
- `MULTISELECTLOOKUP` (10) - Multiple selection from a value list
- `INTEGER64` (11) - A 64-bit integer
- `FILETIME` (12) - FILETIME (a 64-bit integer)
- `MULTILINETEXT` (13) - Multi-line text
- `ACL` (14) - The access control list (ACL)

**Usage:**

```
use CodebarAg\MFiles\Enums\MFDataTypeEnum;

$dataType = MFDataTypeEnum::TEXT;
$dataTypeValue = $dataType->value; // 1
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Codebar Solutions AG](https://github.com/codebar-ag)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance86

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 86% 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 ~16 days

Recently: every ~1 days

Total

16

Last Release

44d ago

Major Versions

v12.5.0 → v13.02025-10-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/fd1bbe54b79d041b513a286058b6fa0c479343f82147da3e63eefdf29c2fa6cb?d=identicon)[codebar](/maintainers/codebar)

---

Top Contributors

[![StanBarrows](https://avatars.githubusercontent.com/u/10268813?v=4)](https://github.com/StanBarrows "StanBarrows (37 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

dmslaravelm-filespackagephplaravelcodebar-agcodebar Solutions AGm-fileslaravel-m-files

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/codebar-ag-laravel-m-files/health.svg)

```
[![Health](https://phpackages.com/badges/codebar-ag-laravel-m-files/health.svg)](https://phpackages.com/packages/codebar-ag-laravel-m-files)
```

###  Alternatives

[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1221.1k](/packages/codebar-ag-laravel-docuware)[maestroerror/laragent

Power of AI Agents in your Laravel project

630106.4k](/packages/maestroerror-laragent)[codebar-ag/laravel-zammad

Zammad integration with Laravel

106.1k](/packages/codebar-ag-laravel-zammad)[spatie/laravel-rdap

Perform RDAP queries in a Laravel app

72108.3k2](/packages/spatie-laravel-rdap)[sunchayn/nimbus

A Laravel package providing an in-browser API client with automatic schema generation, live validation, and built-in authentication with a touch of Laravel-tailored magic for effortless API testing.

29428.0k](/packages/sunchayn-nimbus)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

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