diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b26a9a9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at https://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..b0f1bdf --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +# Path-based git attributes +# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html + +# Ignore all unnecessary files with "export-ignore". +/.editoconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/phpcs.xml export-ignore +/README.md export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4fbb073 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/vendor/ +/composer.lock diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..ff7e5f5 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# The MIT License (MIT) + +Copyright (c) 2020 Nicolas Hedger + +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in +> all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +> THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..903960b --- /dev/null +++ b/README.md @@ -0,0 +1,70 @@ +# Laravel kDrive Storage Driver + +[![Latest Version on Packagist][icon-version]][link-packagist] +[![Software License][icon-license]](LICENSE.md) +[![Total Downloads][icon-license]][link-packagist] + +This package contains an [Infomaniak kDrive](https://www.infomaniak.com/en/kdrive/) storage driver for Laravel. + +## Installation +Via [Composer](https://getcomposer.org/) +```shell script +composer require infomaniak/laravel-kdrive +``` + +### Register the Service Provider +Starting with laravel 5.5, the Service Provider is automatically registered so may skip this instruction. + +Add the Service provider to your `config/app.php` file: + +```php +'providers' => [ + \Infomaniak\KDrive\KDriveServiceProvider::class, +], +``` + +### Configure a new disk +Add a new disk to your `config/filesystems.php` file: + +```php +'disks' => [ + 'kdrive' => [ + 'driver' => 'kdrive', + 'id' => env('KDRIVE_ID'), + 'username' => env('KDRIVE_USERNAME'), + 'password' => env('KDRIVE_PASSWORD'), + 'prefix' => env('KDRIVE_PREFIX', ''), + ] +], +``` + +### Setup your .env file +Add your credentials to your `.env` file. See [Credentials](#credentials) for more information on obtaining them. + +``` +KDRIVE_ID=123456 +KDRIVE_USERNAME=john.doe@example.tld +KDRIVE_PASSWORD=******************** +KDRIVE_PREFIX= +``` + +The `KDRIVE_PREFIX` is optional an you may remove it from you `.env` file is you do not use it. This settings allows you to define another folder as your root. + +## Credentials +To be able to connect to your kDrive, you'll need the following information. + +1. Your kDrive ID ([Find your kDrive ID](#find-your-kdrive-id)) +2. Your login email address (the one you'd use on https://manager.infomaniak.com) +3. A unique application password ([Generate an application password](https://manager.infomaniak.com/v3/profile/application-password)) + +### Find your kDrive ID +1. Connect to your kDrive directly on Infomaniak +2. Find your drive's ID in the URL : `https://drive.infomaniak.com/app/drive/[ID]/files` + +## License +The MIT License (MIT). Please see the [LICENSE](LICENSE.md) for more information. + +[icon-version]: https://img.shields.io/packagist/v/infomaniak/laravel-kdrive?style=flat-square +[icon-license]: https://img.shields.io/packagist/l/infomaniak/laravel-kdrive?style=flat-square +[icon-downloads]: https://img.shields.io/packagist/dt/infomaniak/laravel-kdrive?style=flat-square +[link-packagist]: https://packagist.org/packages/infomaniak/laravel-kdrive diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..046aa60 --- /dev/null +++ b/composer.json @@ -0,0 +1,36 @@ +{ + "name": "infomaniak/laravel-kdrive", + "description": "Infomaniak kDrive Storage driver for Laravel", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Nicolas Hedger", + "email": "nicolas.hedger@infomaniak.com" + } + ], + "autoload": { + "psr-4": { + "Infomaniak\\KDrive\\": "src/" + } + }, + "minimum-stability": "stable", + "require": { + "infomaniak/flysystem-kdrive": "^1.0", + "illuminate/support": "^5.0|^6.0|^7.0" + }, + "require-dev": { + "squizlabs/php_codesniffer": "^3.5" + }, + "scripts": { + "check-style": "phpcs src", + "fix-style": "phpcbf src" + }, + "extra": { + "laravel": { + "providers": [ + "Infomaniak\\KDrive\\KDriveServiceProvider" + ] + } + } +} diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..65b745b --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,14 @@ + + + The coding standard of infomaniak/laravel-kdrive package + + + + + + + + + + + diff --git a/src/KDriveServiceProvider.php b/src/KDriveServiceProvider.php new file mode 100644 index 0000000..a7addb0 --- /dev/null +++ b/src/KDriveServiceProvider.php @@ -0,0 +1,26 @@ +