dev-master
9999999-devImage manager with AWS S3 integration
MIT
The Requires
The Development Requires
by Matt Margolin
Wallogit.com
2017 © Pedro Peláez
Image manager with AWS S3 integration
This package is created as a PSR-0 namespaced library that is installable via PHP Composer., (*1)
Very little configuration is required to use this library., (*2)
Simply configure various image directories to be monitored and automatically pushed to S3, optionally deleting files after upload., (*3)
Include this repository within your composer.json package of your library, (*4)
Run composer install, (*5)
If you want to test using Vagrant, be sure to install Ansible dependencies:, (*6)
ansible-galaxy install -v -r ansible/requirements.yml -p ansible/roles, (*7)
$ssh_host = "127.0.0.1"; // or DNS name
$ssh_port = 22;
$ssh_user = "vagrant";
$ssh_public_key = "/path/to/public_key";
$ssh_private_key = "/path/to/private_key";
$ssh_config = new \mm0\ImageManager\Configuration\SSH (
$ssh_host,
$ssh_port,
$ssh_user,
$ssh_public_key,
$ssh_private_key,
'', // ssh key passphrase
array('hostkey' => 'ssh-rsa')
);
We then use this configuration object to create a connection object:, (*8)
$connection = new \mm0\ImageManager\SSH\Connection($ssh_config); $connection->setSudoAll(true); // set this to true if you are using a non-root user to SSH
Alternatively, instead of SSH'ing into your MySQL Box, you can also run this library directly on your server using a LocalShell/Connection Object, (*9)
$connection = new \mm0\ImageManager\LocalShell\Connection()
Save Modules determine where we will store our backups. You can specify one or more save modules in an array, (*10)
To date, we have only implemented AWS S3 and GCS Save Modules. The goal is to have additional modules implemented using the same interfaces for us to be able to archive onto more providers by simply adding the configuration to the save module array, (*11)
In order to use the local module, we must be using a LocalShell Connection as this library and composer dependency (AWS-PHP-SDK) is required., (*12)
With an SSH Connection, we are limited in that we don't have a copy of this library in th, (*13)
// Specify the storage module for the backup to use (local or remote SSH)
$s3_save_module = new \mm0\ImageManager\AWS\Uploader(
$connection,
$bucket,
$region,
$concurrency
);
./Examples directory or TestsConfiguration for AWS, GCS(Optional):, (*14)
You must configure your aws cli by adding api key credentials to:
/home/vagrant/.aws/boto
and configure gsutil by running
gsutil configure
You may have to update tests to reference personal buckets as well.
Start Vagrant:, (*15)
vagrant up, (*16)
Log into VM:, (*17)
vagrant ssh, (*18)
CD to shared Directory:, (*19)
cd /var/www, (*20)
Install composer packages:, (*21)
composer install --dev, (*22)
Create an SSH Key, (*23)
ssh-keygen ( press enter a few times ), (*24)
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys, (*25)
Run PHPUnit, (*26)
./vendor/bin/phpunit -v --debug, (*27)
To see full test coverage, run:, (*28)
./vendor/bin/phpunit --debug --verbose --coverage-html html
Copyright (c) 2017, Matt Margolin, (*29)
All rights reserved., (*30)
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:, (*31)
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer., (*32)
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution., (*33)
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission., (*34)
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE., (*35)
Matt Margolin, (*36)
mm0 on github, (*37)
Image manager with AWS S3 integration
MIT