{"id":20269359,"url":"https://github.com/vatri/google-drive-bundle","last_synced_at":"2025-04-11T04:01:22.165Z","repository":{"id":37587590,"uuid":"190745643","full_name":"vatri/Google-Drive-Bundle","owner":"vatri","description":"Google Drive API Bundle for Symfony 4","archived":false,"fork":false,"pushed_at":"2024-09-24T20:51:24.000Z","size":186,"stargazers_count":9,"open_issues_count":4,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T02:01:36.836Z","etag":null,"topics":["composer-package","google-drive-api","php","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vatri.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-07T13:12:03.000Z","updated_at":"2024-09-24T20:50:19.000Z","dependencies_parsed_at":"2024-11-14T12:38:00.553Z","dependency_job_id":null,"html_url":"https://github.com/vatri/Google-Drive-Bundle","commit_stats":{"total_commits":68,"total_committers":9,"mean_commits":7.555555555555555,"dds":0.5735294117647058,"last_synced_commit":"95a036898477b91b741c9301743e0382b10d5723"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vatri%2FGoogle-Drive-Bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vatri%2FGoogle-Drive-Bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vatri%2FGoogle-Drive-Bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vatri%2FGoogle-Drive-Bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vatri","download_url":"https://codeload.github.com/vatri/Google-Drive-Bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248339256,"owners_count":21087214,"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","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":["composer-package","google-drive-api","php","symfony","symfony-bundle"],"created_at":"2024-11-14T12:24:40.232Z","updated_at":"2025-04-11T04:01:22.107Z","avatar_url":"https://github.com/vatri.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google-Drive-Bundle\n\nGoogle Drive API Bundle for Symfony 6 and 7.\n\n# Features\n\n- Authorize via Google API\n- Manage Google Drive files and folders\n  - Create a folder (recursively)\n  - Check if a folder exists\n  - Find a file by ID\n  - Delete a file\n  - Download file\n  - List files\n  - Copy a file to specific directory\n  - Upload a file\n  - Add \"starred\" flag to a file/folder\n  - Rename resource (file or folder)\n\nInstallation\n============\n\nApplications that use Symfony Flex\n----------------------------------\n\nOpen a command console, enter your project directory and execute:\n\n```console\n$ composer require vatri/google-drive-bundle\n```\n\nApplications that don't use Symfony Flex\n----------------------------------------\n\n### Step 1: Download the Bundle\n\nOpen a command console, enter your project directory and execute the\nfollowing command to download the latest stable version of this bundle:\n\n```console\n$ composer require vatri/google-drive-bundle\n```\n\nThis command requires you to have Composer installed globally, as explained\nin the [installation chapter](https://getcomposer.org/doc/00-intro.md)\nof the Composer documentation.\n\n### Step 2: Enable the Bundle\n\nThen, enable the bundle by adding it to the list of registered bundles\nin the `config/bundles.php` file of your project:\n\n```php\n// config/bundles.php\n\nreturn [\n    // ...\n    App\\Vatri\\GoogleDriveBundle\\VatriGoogleDriveBundle::class =\u003e ['dev' =\u003e true, 'test' =\u003e true],\n];\n```\n\nUsage\n============\n\n### 1. Add/edit following variables in your _.env_ file:\n\n```\nVATRI_GOOGLE_DRIVE_CREDENTIALS_FILE=config/YOUR_FILENAME.json`\nVATRI_GOOGLE_DRIVE_REDIRECT_AFTER_AUTH=/\n```\n\n**Don't forget to replace default values with yours.**\n\n### 2. Create (or check if exists) _/config/routes/vatri_google_drive.yaml_ file with following contents:\n\n```yaml\nvatri_google_drive:\n    resource: '@VatriGoogleDriveBundle/Controller/'\n    type:     annotation\n```\n\n### 3. Download and configure JSON credentials file\n\nDownload your JSON credentials file from Google Console to _/config_ folder within Symfony project.\n\nEdit following variables in _.env_ file:\n\n  `VATRI_GOOGLE_DRIVE_CREDENTIALS_FILE=config/google-drive-api-client_secrets.json-example.json`\n  `VATRI_GOOGLE_DRIVE_REDIRECT_AFTER_AUTH=/path/to/your/route`\n\n### 4. Check and use AuthController\n\nAuthController is default controller required for authorization of users via Google API. By default it saves an access token to cookie. \n\nAlso note that if you use this controller for authorization, you will add below route as callback URL in Google Console Credentials configuration.\n\n1. Run\n\n`php bin/console debug:router`\n\nand check if you have a route like this:\n\n```\nvatri_google_drive_auth       ANY      ANY      ANY    \u003chref=\u003e/vatri_google_drive/auth\n```\n\n2. Now in order to authenticate users, you need to add link to the route like this:\n\n```html\n\u003ca href=\"{{ path('vatri_google_drive_auth') }}\"\u003e\n    Login\n\u003c/a\u003e\n```\n\n### 5. Use DriveApiService in your controller or another Symfony part like this:\n\n```php\n use Vatri\\GoogleDriveBundle\\Service\\DriveApiService;\n ...\n\n public function test(DriveApiService $driveApiService): Response\n {\n   if($driveApiService-\u003eisTokenExpired()){\n      return $this-\u003eredirectToRoute( $driveApiService-\u003egetAuthRouteName() );\n   }\n   $folderId = '[YOUR ID]';\n   $res = $driveApiService-\u003elistFiles($folderId, false, true );\n   dd($res);\n }\n```\n\n\n### 6. Check if Drive API access token is expired and authorize if required:\n\nAdd the following code to your controller or other part:\n\n```php\nif($driveApiService-\u003eisTokenExpired()){\n   \n   // When auth is finished, redirect back to this URL:\n   $driveApiService-\u003esetRedirectPathAfterAuth(\n      $this-\u003eget('request_stack')-\u003egetCurrentRequest()-\u003egetRequestUri()\n   );\n   \n   // Redirect\n   return $this-\u003eredirectToRoute( $driveApiService-\u003egetAuthRouteName() );\n}\n```\n\n# Roadmap\n\n### Version 1.2\n\n- [ ] Symfony Flex recipe\n- [ ] Logout controller\n- [ ] Configure token storage (including custom one)\n\n### Version 1.1\n\n- [x] renameFolder() method\n\n### Version 1.0\n\n- [x] Automatically refresh access_token using refresh_token\n- [x] Uniformed responses from _DriveApiService_ (a class)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvatri%2Fgoogle-drive-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvatri%2Fgoogle-drive-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvatri%2Fgoogle-drive-bundle/lists"}