A Gitlab Storage filesystem for Flysystem.
This package contains a Flysystem adapter for Gitlab. Under the hood, Gitlab's Repository (files) API v4 is used.
composer require royvoetman/flysystem-gitlab-storage
// Create a Gitlab Client to talk with the API
$client = new Client('personal-access-token', 'project-id', 'branch', 'base-url');
// Create the Adapter that implentents Flysystems AdapterInterface
$adapter = new GitlabAdapter($client));
// Create FileSystem
$filesystem = new Filesystem($adapter);
// write a file
$filesystem->write('path/to/file.txt', 'contents');
// update a file
$filesystem->update('path/to/file.txt', 'new contents');
// read a file
$contents = $filesystem->read('path/to/file.txt');
// check if a file exists
$exists = $filesystem->has('path/to/file.txt');
// delete a file
$filesystem->delete('path/to/file.txt');
// rename a file
$filesystem->rename('filename.txt', 'newname.txt');
// copy a file
$filesystem->copy('filename.txt', 'duplicate.txt');
// delete a directory
$filesystem->deleteDir('path/to/directory');
// see https://flysystem.thephpleague.com/api/ for full list of available functionality
Gitlab supports server side API authentication with Personal Access tokens
For more information on how to create your own Personal Access token: Gitlab Docs
Every project in Gitlab has its own Project ID. It can be found at to top of the frontpage of your repository. See
This will be the URL where you host your gitlab server (e.g. https://gitlab.com)
In some cases, the need arises to debug the Http Messeages returned by the Gitlab API. For this need, the adapter has a built-in debug mode
. When this mode is enabled, it will tell the adapter to prevent catching the GuzzleHttp\Exception\GuzzleException
.
To check for the current state of de adaptor the isDebugEnabled
method can be called on the adapter.
Enabling debug mode can be done with either of the following two options:
$adapter = new GitlabAdapter($client, '', true); // Third parameter defines debug mode
$adapter->setDebug(true);
Please see CHANGELOG for more information what has changed recently.
Contributions are welcome and will be fully credited. We accept contributions via Pull Requests on Github.
- PSR-2 Coding Standard - The easiest way to apply the conventions is to install PHP Code Sniffer.
- Document any change in behaviour - Make sure the
README.md
and any other relevant documentation are kept up-to-date. - Create feature branches - Don't ask us to pull from your master branch.
- One pull request per feature - If you want to do more than one thing, send multiple pull requests.
The MIT License (MIT). Please see License File for more information.