PHP code example of shadiakiki1986 / flysystem-git
1. Go to this page and download the library: Download shadiakiki1986/flysystem-git library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shadiakiki1986 / flysystem-git example snippets
League\Flysystem\Filesystem;
// prepare adapter
// http://github.com/shadiakiki1986/git-rest-api-client-php
$git = new \GitRestApi\Client('http://localhost:8081');
// for read-write, ries with a long history
// for writing to the remote repo, i.e. if "push" variable below is true, need to set username and email
// not needed if read-only usage
$repo->putConfig('user.name','phpunit test flysystem-git');
$repo->putConfig('user.email','[email protected]');
// initialize filesystem for further usage
$push = false; // set to false to make read/write possible without pushing to remote. Set to true to push to remote
$pull = true; // set to true to skip pulling from the remote repository at each transaction in order to save on time
$adapter = new \shadiakiki1986\Flysystem\Git($repo,$push,$pull);
$filesystem = new Filesystem($adapter);
// read a file
$contents = $filesystem->read('bla');
// if username/password above are correct, can also update the file
$filesystem->update('bla','some new content');
// write to a new file
$filesystem->write('new folder/new file','content of file');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.