Download the PHP package danilowa/laravel-easy-cloud-storage without Composer

On this page you can find all versions of the php package danilowa/laravel-easy-cloud-storage. 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 laravel-easy-cloud-storage

Laravel EasyCloudStorage

Laravel EasyCloudStorage is a flexible and intuitive package designed to simplify cloud storage management within Laravel applications. It provides a clean interface for interacting with various storage providers, including local disks, Amazon S3, and Google Cloud Storage.

Table of Contents

Installation

To install the package, run the following command via Composer:

After installation, the service provider will be automatically registered. To customize the configuration, publish the package's config file:

Configuration

The configuration file is located at config/easycloudstorage.php. The main settings include:

Usage

After configuration, you can use the EasyCloudStorage package for various operations.

Initial Example

This section demonstrates how to perform a file upload using the EasyCloudStorage package. The example illustrates the process of uploading a file to a specified directory, along with optional logging and error handling configurations.

Explanation of the Code:

  1. Use Statement:

    • The use statement imports the EasyStorage facade, which allows you to access storage functionalities easily.
  2. Uploading a File:

    • The upload method is called on the EasyStorage facade, taking in:
      • $uploadedFile: An instance of UploadedFile, typically obtained from a file upload in an HTTP request.
      • 'uploads/myfile.txt': The destination path where the file will be stored on the disk.
  3. Error Logging Configuration:

    • The withLog method allows you to control error logging during the upload process:
      • Enabled (true): Error logging is activated for the upload operation.
      • Disabled (false): Turns off error logging.
      • Default Behavior: If called without parameters, it assumes true, enabling error logging by default.
      • Configuration Fallback: If not used, the package utilizes the error logging setting specified in the configuration file.
  4. Error Handling Configuration:

    • The withError method configures whether to throw exceptions when errors occur during the upload process:
      • Throw Exceptions (true): System will throw exceptions for any encountered errors.
      • Do Not Throw Exceptions (false): Prevents exceptions from being thrown.
      • Default Behavior: If called without parameters, it defaults to true.
      • Configuration Fallback: Follows the error handling configuration specified in the configuration file.
  5. Setting the Disk:

    • The setDisk method allows you to manually specify the storage disk to be used, overriding the default disk configuration.
  6. Success Check:
    • After attempting the upload, the result is stored in $filePath. This variable will either contain a string representing the path to the uploaded file or false if the upload failed.
    • The if statement checks the value of $filePath to determine the success of the upload:
      • Successful Upload: If $filePath is of type string, it prints a message displaying the path of the uploaded file.
      • Unsuccessful Upload: If $filePath is false, it indicates that the upload failed, and an error message is displayed.

File Operations

Uploading Files

Upload a file to the specified path on the storage disk.

Downloading Files

Download a file from the specified path on the storage disk.

Getting File URL

Retrieve the URL of the stored file.

Deleting Files

Delete a file at the specified path.

Checking File Existence

Check if a file exists at the specified path.

Copying Files

Copy a file from a source path to a destination path.

Moving Files

Move or rename a file.

$to`: The new path.

Getting File Size

Retrieve the size of a file in bytes.

Getting Last Modified Time

Get the last modified timestamp of a file.

Getting Metadata

Retrieve metadata for a file.

Setting Metadata

Set metadata for a file.

Listing Files

List files in a specified directory.

Prepending and Appending Data

Prepend or append data to a file.

Creating and Deleting Directories

Create or delete a directory.

Error Handling

You can enable error logging and exception throwing through the configuration or method chaining. Use the withLog() and withError() methods to customize error handling per operation.

Driver-Specific Method Availability

It's important to note that not all storage drivers will support every method available in the EasyCloudStorage package. The functionality provided depends exclusively on the capabilities of each specific driver, such as Google Cloud Storage, Amazon S3, and others.

For example, while uploading and deleting files are common operations across most drivers, certain methods like managing metadata or creating directories may not be supported by all drivers.

Rest assured, the EasyCloudStorage package has built-in logic to handle these discrepancies gracefully. If a method is not available for a specific driver, an informative error will be returned, ensuring that you are promptly notified of the limitation. This design allows you to implement your logic without the worry of unexpected failures, promoting a smooth development experience.

Design Patterns: Facade and Contracts

Facade

The Facade pattern in Laravel offers a simple and intuitive interface to access classes within the application’s service container. By utilizing the EasyStorage facade, you can invoke methods directly without having to resolve the underlying service each time. This approach not only streamlines your code but also improves readability, allowing you to concentrate on building features rather than managing complex dependencies. The result is a cleaner and more efficient API that enhances your development experience.

Contracts

Contracts in Laravel define the expected behaviors of services, providing a clear guideline for how they should operate. By utilizing contracts, you ensure that your application can easily switch between different implementations of a service without affecting the code that interacts with it. This flexibility is beneficial for developers, as it allows for easier updates or changes to the underlying logic without requiring significant code alterations.

For users, this means a more reliable and maintainable application. You can confidently integrate new features or optimize existing ones while ensuring that the core functionality remains intact. By adhering to this practice, you also promote a clean architecture that is easier to understand and extend, ultimately enhancing the long-term sustainability of your codebase.

License

This package is licensed under the MIT License. See the LICENSE file for details.


All versions of laravel-easy-cloud-storage with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1|^8.2
laravel/framework Version ^8.0|^9.0|^10.0|^11.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 danilowa/laravel-easy-cloud-storage contains the following files

Loading the files please wait ....