Download the PHP package benmajor/sirv-s3-client without Composer

On this page you can find all versions of the php package benmajor/sirv-s3-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sirv-s3-client

SirvPHP Client

This library is a Sirv S3 Client written in PHP. It is a port of the official SDK released by Sirv with a few modifications, and rebuilt as a Composer package.


Installation:

The easiest way to install the client is using Composer:

Since there are no external dependencies (other than PHP >= 5.4 and with the cURL module installed), you can also download the single PHP class from the src directory and include it in your code using PHP's require statement:


Usage:

This client provides some utility functions to easily work with the Sirv S3 buckets and upload content directly from your project using PHP. Usage and function reference is as follows:

1. Creating the client:

We must first create a client before using any of the functions. This is done easily by instantiating the class using your Sirv S3 Bucket, S3 Key and S3 Secret (all of which are located in your Settings page) as follows:

Once the client has been instantiated, you can check the connection is valid and live using the testConnection() method:

2. Check if resource exists:

To check if a folder exists within the Bucket, simply use checkIfObjectExists() by passing a relative folder path to the method. The method returns true if the folder exists, or false if not:

It's also possible to check if a specific file exists within a folder by passing the basename of the file (including extension) as a second parameter to the checkIfObjectExists method:

Returns true if the resource exists, otherwise false.

3. Get a list of resources:

To get a list of resources (i.e. folders and files) that exist, use the getBucketContents() method:

Note that we have specified a folder path above to retrieve only resources that exist within the example/folder directory. The method can also be called with no parameter to retrieve the contents of the Bucket's root.

This method returns an object as follows:

4. Creating folders:

To create a new folder, simply use the createFolder() method and pass the relative path to the folder to be created as the first argument:

Returns true if the folder was successfully created, otherwise false.

5. Uploading files:

Files can be easily uploaded using the uploadFile() method. The first parameter is the destination folder and filename to which the file should be uploaded. The second parameter must contain a relative path to a file that already exists on the server (it can also be a reference to the temporary file created following a file upload).

Two examples are given below; one using a file that already exists, and another of uploading a user-uploaded file from PHP's temporary directory.

Upload existing file on server:

Uploading a temporary file:

6. Downloading files:

The getFile() method can be used to retrieve the raw contents of a file from the Bucket. The string can then be used to create a file on the local filesystem (using file_put_contents() or similar). If the file does not exist on the S3 Bucket, or fails for another reason, the method returns an empty string, so it is advisable to check the returned value before using it:

7. Copying files:

Sometimes, we may wish to copy a file from one directory to another within the Bucket. To do this, use the copyFile() method. The first paramater is the path of the source file, and the second parameter is its destination:

Files can also be copied to the same directory, but must be renamed:

8. Renaming files:

It is sometimes necessary to rename a file within the Bucket. This can be done using the renameFile() method, and passing the relative path as the first parameter:

9. Deleting files:

The deleteFile() method can be used to delete files from the Bucket instance. The relative path of the resource to be deleted should be passed as the first parameter of this method.


Credits:

The package is heavily based on the official SDK released by Sirv, which itself is a simplified version of the AWS PHP SDK.


License:

This Composer package is released under the MIT License as follows:

Copyright (c) 2020 Ben Major

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.


All versions of sirv-s3-client with dependencies

PHP Build Version
Package Version
Requires php Version >= 5.6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package benmajor/sirv-s3-client contains the following files

Loading the files please wait ....