{"id":34539775,"url":"https://github.com/codebar-ag/laravel-m-files","last_synced_at":"2026-01-20T17:55:32.282Z","repository":{"id":305208804,"uuid":"976987158","full_name":"codebar-ag/laravel-m-files","owner":"codebar-ag","description":null,"archived":false,"fork":false,"pushed_at":"2025-10-29T17:13:55.000Z","size":711,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-29T18:41:27.753Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codebar-ag.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-03T06:53:08.000Z","updated_at":"2025-10-29T16:58:54.000Z","dependencies_parsed_at":"2025-08-04T15:12:47.398Z","dependency_job_id":"ed49b706-4f68-40cb-9419-0d581d4c3d80","html_url":"https://github.com/codebar-ag/laravel-m-files","commit_stats":null,"previous_names":["codebar-ag/laravel-m-files"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/codebar-ag/laravel-m-files","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebar-ag%2Flaravel-m-files","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebar-ag%2Flaravel-m-files/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebar-ag%2Flaravel-m-files/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebar-ag%2Flaravel-m-files/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codebar-ag","download_url":"https://codeload.github.com/codebar-ag/laravel-m-files/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebar-ag%2Flaravel-m-files/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27996112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-24T06:14:57.892Z","updated_at":"2025-12-24T06:14:58.579Z","avatar_url":"https://github.com/codebar-ag.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://banners.beyondco.de/Laravel%20M-Files.png?theme=light\u0026packageManager=composer+require\u0026packageName=codebar-ag%2Flaravel-m-files\u0026pattern=circuitBoard\u0026style=style_1\u0026description=An+opinionated+way+to+integrate+M-Files+with+Laravel\u0026md=1\u0026showWatermark=0\u0026fontSize=175px\u0026images=document-report\" alt=\"Laravel M-Files banner with description and logo\"\u003e\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/codebar-ag/laravel-m-files.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/laravel-m-files)\n[![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)\n[![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)\n[![Larastan](https://img.shields.io/badge/Larastan-Level%205-brightgreen.svg)](https://github.com/larastan/larastan)\n[![Total Downloads](https://img.shields.io/packagist/dt/codebar-ag/laravel-m-files.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/laravel-m-files)\n\n# Laravel M-Files Integration\n\nA Laravel package providing DTOs and requests for integrating with M-Files REST API.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require codebar-ag/laravel-m-files\n```\n\n## Configuration\n\nPublish the configuration file:\n\n```bash\nphp artisan vendor:publish --provider=\"CodebarAg\\MFiles\\MFilesServiceProvider\"\n```\n\nAdd your M-Files authentication credentials to your `.env` file:\n\n```env\nM_FILES_URL=https://your-mfiles-server.com\nM_FILES_USERNAME=your-username\nM_FILES_PASSWORD=your-password\nM_FILES_VAULT_GUID=ABC0DE2G-3HW-QWCQ-SDF3-WERWETWETW\nM_FILES_CACHE_DRIVER=file\n```\n\n### Configuration Options\n\nThe package supports the following configuration options:\n\n- `M_FILES_URL` - Your M-Files server URL\n- `M_FILES_USERNAME` - Your M-Files username\n- `M_FILES_PASSWORD` - Your M-Files password\n- `M_FILES_VAULT_GUID` - The vault GUID to connect to\n- `M_FILES_CACHE_DRIVER` - Cache driver for storing authentication tokens (default: file)\n\n## Authentication\n\nThe package provides automatic authentication token management with caching support.\n\n### M-Files Connector\n\n```php\nuse CodebarAg\\MFiles\\Connectors\\MFilesConnector;\nuse CodebarAg\\MFiles\\DTO\\ConfigWithCredentials;\n\n$config = new ConfigWithCredentials(\n    url: 'https://your-mfiles-server.com',\n    vaultGuid: '{ABC0DE2G-3HW-QWCQ-SDF3-WERWETWETW}',\n    username: 'your-username',\n    password: 'your-password',\n    cacheDriver: 'file'\n);\n\n$connector = new MFilesConnector(config: $config);\n```\n\n### Authentication\n\nAuthentication is handled automatically by the `MFilesConnector`. When you create a connector instance with your credentials, it will automatically:\n\n1. **Cache authentication tokens** - Tokens are cached for 1 hour to avoid repeated login requests\n2. **Include authentication headers** - The `X-Authentication` header is automatically added to all requests\n3. **Handle token refresh** - When tokens expire, new ones are automatically obtained\n\n```php\nuse CodebarAg\\MFiles\\Requests\\LogInToVaultRequest;\n\n// Manual authentication (if needed)\n$request = new LogInToVaultRequest(\n    url: 'https://your-mfiles-server.com',\n    vaultGuid: '{ABC0DE2G-3HW-QWCQ-SDF3-WERWETWETW}',\n    username: 'your-username',\n    password: 'your-password',\n);\n\n$token = $request-\u003esend()-\u003edto();\n// Returns authentication token as string\n```\n\n## Requests\n\n### Authentication Requests\n\n#### LogInToVaultRequest\n\nGets an authentication token using username/password credentials.\n\n**Constructor Parameters:**\n- `url` (string) - M-Files server URL\n- `vaultGuid` (string) - Vault GUID\n- `username` (string) - M-Files username\n- `password` (string) - M-Files password\n\n**Request:**\n```php\nuse CodebarAg\\MFiles\\Requests\\LogInToVaultRequest;\n\n$request = new LogInToVaultRequest(\n    url: 'https://your-mfiles-server.com',\n    vaultGuid: '{ABC0DE2G-3HW-QWCQ-SDF3-WERWETWETW}',\n    username: 'your-username',\n    password: 'your-password',\n);\n```\n\n**Response:**\n```php\n$token = $request-\u003esend()-\u003edto();\n// Returns authentication token as string\n```\n\n### File Requests\n\n#### UploadFileRequest\n\nUploads a file to M-Files.\n\n**Constructor Parameters:**\n- `fileContent` (string) - File content\n- `fileName` (string) - File name\n\n**Request:**\n```php\nuse CodebarAg\\MFiles\\Requests\\UploadFileRequest;\n\n$request = new UploadFileRequest(\n    fileContent: $fileContent,\n    fileName: 'document.pdf'\n);\n```\n\n**Response:**\n```php\n$uploadedFile = $connector-\u003esend($request)-\u003edto();\n// Returns array with file information including Title, Extension, and other metadata\n```\n\n#### CreateSingleFileDocumentRequest\n\nCreates a single file document in M-Files.\n\n**Constructor Parameters:**\n- `title` (string) - Document title\n- `files` (array) - Array of uploaded file information\n- `propertyValues` (array) - Array of SetProperty objects for custom properties\n\n**Request:**\n```php\nuse CodebarAg\\MFiles\\Requests\\CreateSingleFileDocumentRequest;\nuse CodebarAg\\MFiles\\DTO\\SetProperty;\nuse CodebarAg\\MFiles\\Enums\\MFDataTypeEnum;\n\n$request = new CreateSingleFileDocumentRequest(\n    title: 'My Document',\n    files: [$uploadedFile]\n);\n```\n\n**Response:**\n```php\nuse CodebarAg\\MFiles\\DTO\\ObjectProperties;\n\n$document = $connector-\u003esend($request)-\u003edto();\n// Returns ObjectProperties DTO with document information\n```\n\n**With Custom Property Values:**\n```php\n$propertyValues = [\n    new SetProperty(propertyDef: 0, dataType: MFDataTypeEnum::TEXT, value: 'Custom Title'),\n    new SetProperty(propertyDef: 5, dataType: MFDataTypeEnum::DATE, value: '2024-01-01'),\n];\n\n$request = new CreateSingleFileDocumentRequest(\n    title: 'Custom Document',\n    files: [$uploadedFile],\n    propertyValues: $propertyValues\n);\n```\n\n#### DownloadFileRequest\n\nDownloads a file from M-Files.\n\n**Constructor Parameters:**\n- `objectType` (int) - Object type ID\n- `objectId` (int) - Object ID\n- `objectVersion` (int) - Object version\n- `fileId` (int) - File ID\n\n**Request:**\n```php\nuse CodebarAg\\MFiles\\Requests\\DownloadFileRequest;\n\n$request = new DownloadFileRequest(\n    objectType: 0,\n    objectId: 123,\n    objectVersion: 1,\n    fileId: 456\n);\n```\n\n**Response:**\n```php\nuse CodebarAg\\MFiles\\DTO\\DownloadedFile;\n\n$downloadedFile = $connector-\u003esend($request)-\u003edto();\n// Returns DownloadedFile DTO with content, name, extension, size, contentType\n```\n\n### Property Requests\n\n#### GetObjectInformationRequest\n\nRetrieves object information and properties from M-Files.\n\n**Constructor Parameters:**\n- `objectType` (int) - Object type ID\n- `objectId` (int) - Object ID\n- `objectVersion` (int) - Object version\n\n**Request:**\n```php\nuse CodebarAg\\MFiles\\Requests\\GetObjectInformationRequest;\n\n$request = new GetObjectInformationRequest(\n    objectType: 0,\n    objectId: 123,\n    objectVersion: 1\n);\n```\n\n**Response:**\n```php\nuse CodebarAg\\MFiles\\DTO\\ObjectProperties;\n\n$objectProperties = $connector-\u003esend($request)-\u003edto();\n// Returns ObjectProperties DTO with object information and properties\n```\n\n#### SetPropertiesRequest\n\nSets properties for an existing object in M-Files.\n\n**Constructor Parameters:**\n- `objectType` (int) - Object type ID\n- `objectId` (int) - Object ID\n- `objectVersion` (int) - Object version (-1 for latest)\n- `propertyValues` (array) - Array of SetProperty objects\n\n**Request:**\n```php\nuse CodebarAg\\MFiles\\Requests\\SetPropertiesRequest;\nuse CodebarAg\\MFiles\\DTO\\SetProperty;\nuse CodebarAg\\MFiles\\Enums\\MFDataTypeEnum;\n\n$propertyValues = [\n    new SetProperty(1856, MFDataTypeEnum::BOOLEAN, true),\n    new SetProperty(0, MFDataTypeEnum::TEXT, 'Updated Title'),\n];\n\n$request = new SetPropertiesRequest(\n    objectType: 140,\n    objectId: 1770,\n    objectVersion: -1,\n    propertyValues: $propertyValues\n);\n```\n\n**Response:**\n```php\nuse CodebarAg\\MFiles\\DTO\\ObjectProperties;\n\n$objectProperties = $connector-\u003esend($request)-\u003edto();\n// Returns ObjectProperties DTO with updated object information\n```\n\n## DTOs\n\n### Configuration DTOs\n\n#### ConfigWithCredentials\n\nRepresents M-Files configuration with authentication credentials.\n\n**Properties:**\n- `url` (string) - M-Files server URL\n- `vaultGuid` (string) - Vault GUID\n- `username` (string) - M-Files username\n- `password` (string) - M-Files password\n- `cacheDriver` (string|null) - Cache driver for tokens\n\n**Methods:**\n- `fromArray(array $data): self` - Static factory method\n- `toArray(): array` - Converts to array format\n\n**Usage:**\n```php\nuse CodebarAg\\MFiles\\DTO\\ConfigWithCredentials;\n\n$config = new ConfigWithCredentials(\n    url: 'https://your-mfiles-server.com',\n    username: 'your-username',\n    password: 'your-password',\n    vaultGuid: '{ABC0DE2G-3HW-QWCQ-SDF3-WERWETWETW}',\n    cacheDriver: 'file'\n);\n\n// Using static factory method\n$config = ConfigWithCredentials::fromArray([\n    'url' =\u003e 'https://your-mfiles-server.com',\n    'username' =\u003e 'your-username',\n    'password' =\u003e 'your-password',\n    'vaultGuid' =\u003e '{ABC0DE2G-3HW-QWCQ-SDF3-WERWETWETW}',\n    'cacheDriver' =\u003e 'file'\n]);\n```\n\n### File DTOs\n\n#### File\n\nRepresents a file in M-Files.\n\n**Properties:**\n- `id` (int) - File ID\n- `name` (string) - File name\n- `extension` (string|null) - File extension\n- `version` (int|null) - File version\n- `size` (int|null) - File size in bytes\n\n**Methods:**\n- `fromArray(array $data): self` - Static factory method\n- `toArray(): array` - Converts to array format\n\n**Usage:**\n```php\nuse CodebarAg\\MFiles\\DTO\\File;\n\n$file = new File(\n    id: 456,\n    name: 'document.pdf',\n    extension: 'pdf',\n    version: 1,\n    size: 1024\n);\n\n// Using static factory method\n$file = File::fromArray([\n    'ID' =\u003e 456,\n    'Name' =\u003e 'document.pdf',\n    'Extension' =\u003e 'pdf',\n    'Version' =\u003e 1,\n    'Size' =\u003e 1024\n]);\n```\n\n#### DownloadedFile\n\nRepresents a downloaded file with content and metadata.\n\n**Properties:**\n- `name` (string|null) - File name\n- `extension` (string|null) - File extension\n- `size` (int|null) - File size in bytes\n- `contentType` (string|null) - MIME content type\n- `content` (string) - File content\n\n**Methods:**\n- `fromArray(array $data): self` - Static factory method\n- `toArray(): array` - Converts to array format\n\n**Usage:**\n```php\nuse CodebarAg\\MFiles\\DTO\\DownloadedFile;\n\n$downloadedFile = new DownloadedFile(\n    name: 'document.pdf',\n    extension: 'pdf',\n    size: 1024,\n    contentType: 'application/pdf',\n    content: $fileContent\n);\n\n// Using static factory method\n$downloadedFile = DownloadedFile::fromArray([\n    'name' =\u003e 'document.pdf',\n    'extension' =\u003e 'pdf',\n    'size' =\u003e 1024,\n    'contentType' =\u003e 'application/pdf',\n    'content' =\u003e $fileContent\n]);\n```\n\n### Property DTOs\n\n#### SetProperty\n\nRepresents a property value for creating documents.\n\n**Properties:**\n- `propertyDef` (int) - Property definition ID\n- `dataType` (MFDataTypeEnum) - Property data type\n- `value` (mixed) - Property value\n- `displayValue` (mixed) - Display value (optional)\n\n**Methods:**\n- `fromArray(int $propertyDef, MFDataTypeEnum $dataType, mixed $value, mixed $displayValue = null): self` - Static factory method\n- `toArray(): array` - Converts to array format for API requests\n\n**Usage:**\n```php\nuse CodebarAg\\MFiles\\DTO\\SetProperty;\nuse CodebarAg\\MFiles\\Enums\\MFDataTypeEnum;\n\n$propertyValue = new SetProperty(\n    propertyDef: 0,\n    dataType: MFDataTypeEnum::TEXT,\n    value: 'Sample Text'\n);\n\n// Using static factory method\n$propertyValue = SetProperty::fromArray(\n    propertyDef: 0,\n    dataType: MFDataTypeEnum::TEXT,\n    value: 'Sample Text'\n);\n\n// Convert to array for API requests\n$array = $propertyValue-\u003etoArray();\n```\n\n#### GetProperty\n\nRepresents a property retrieved from M-Files.\n\n**Properties:**\n- `propertyDef` (int) - Property definition ID\n- `dataType` (MFDataTypeEnum) - Property data type\n- `value` (mixed) - Property value\n- `displayValue` (mixed) - Display value\n\n**Methods:**\n- `fromArray(array $data): self` - Static factory method\n- `toArray(): array` - Converts to array format\n\n**Usage:**\n```php\nuse CodebarAg\\MFiles\\DTO\\GetProperty;\n\n$property = GetProperty::fromArray([\n    'PropertyDef' =\u003e 0,\n    'Value' =\u003e [\n        'DataType' =\u003e 1,\n        'Value' =\u003e 'Sample Text',\n        'DisplayValue' =\u003e 'Sample Text'\n    ]\n]);\n```\n\n#### ObjectProperties\n\nRepresents object properties in M-Files.\n\n**Properties:**\n- `classId` (int) - Class ID\n- `objectId` (int) - Object ID\n- `objectTypeId` (int) - Object type ID\n- `objectVersionId` (int) - Object version ID\n- `lastModifiedAt` (CarbonImmutable) - Last modified timestamp\n- `properties` (Collection) - Collection of GetProperty objects\n- `files` (Collection) - Collection of File objects\n\n**Methods:**\n- `fromArray(array $data): self` - Static factory method\n- `toArray(): array` - Converts to array format\n\n**Usage:**\n```php\nuse CodebarAg\\MFiles\\DTO\\ObjectProperties;\n\n$objectProperties = ObjectProperties::fromArray([\n    'Class' =\u003e 1,\n    'ObjVer' =\u003e [\n        'ID' =\u003e 123,\n        'Type' =\u003e 0,\n        'Version' =\u003e 1,\n        'Modified' =\u003e '2024-01-01T00:00:00Z'\n    ],\n    'Properties' =\u003e [],\n    'Files' =\u003e []\n]);\n```\n\n### Enums\n\n#### MFDataTypeEnum\n\nRepresents data types in M-Files.\n\n**Available Values:**\n- `UNINITIALIZED` (0) - Document/Object\n- `TEXT` (1) - Text\n- `INTEGER` (2) - A 32-bit integer\n- `FLOATING` (3) - A double-precision floating point\n- `DATE` (5) - Date\n- `TIME` (6) - Time\n- `TIMESTAMP` (7) - Timestamp\n- `BOOLEAN` (8) - Boolean\n- `LOOKUP` (9) - Lookup (from a value list)\n- `MULTISELECTLOOKUP` (10) - Multiple selection from a value list\n- `INTEGER64` (11) - A 64-bit integer\n- `FILETIME` (12) - FILETIME (a 64-bit integer)\n- `MULTILINETEXT` (13) - Multi-line text\n- `ACL` (14) - The access control list (ACL)\n\n**Usage:**\n```php\nuse CodebarAg\\MFiles\\Enums\\MFDataTypeEnum;\n\n$dataType = MFDataTypeEnum::TEXT;\n$dataTypeValue = $dataType-\u003evalue; // 1\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email security@codebar.ch instead of using the issue tracker.\n\n## Credits\n\n- [Codebar Solutions AG](https://github.com/codebar-ag)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebar-ag%2Flaravel-m-files","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodebar-ag%2Flaravel-m-files","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebar-ag%2Flaravel-m-files/lists"}