Download the PHP package 1tomany/storage-bundle without Composer

On this page you can find all versions of the php package 1tomany/storage-bundle. 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 storage-bundle

Storage Bundle for Symfony

This bundle makes it easy to upload files to remote storage services like Amazon S3, Cloudflare R2, Google Cloud Storage, and Azure Blob Storage. Additionally, it provides a mock storage service to easily test your integrations without requiring a network connection.

Installation

Install the bundle using Composer:

If you're using Amazon S3 or an S3 compatible provider like Cloudflare R2, you'll also need to install the AWS SDK bundle provided by Amazon:

Going forward, any mention of Amazon S3 or AWS assumes you're using Amazon S3 itself or a compatible provider.

Updating .env and .env.test

This bundle does not have a Symfony Flex recipe yet, so you'll have to manually update your .env file by adding the following section:

And update the .env.test file by adding the following section:

STORAGE_SERVICE

The storage provider to use. Possible values are:

STORAGE_BUCKET

The bucket where files will be uploaded.

STORAGE_CUSTOM_URL

The URL to use to reference the uploaded file instead of the canonical URL returned by the provider. Set this value if you use Amazon CloudFront or a public Cloudflare R2 bucket domain to get a publicly accessible file URL:

When set, if an object named users/10/files/avatar.png was uploaded, the following URL would be returned:

Configuring Amazon S3

Installing the aws/aws-sdk-php-symfony package will create a file named config/packages/aws.yaml and update the .env file with following section:

You should add the following environment variable for modern versions of Symfony as well:

I highly recommend taking advantage of Symfony secrets to store encrypted values of the AWS_KEY and AWS_SECRET environment variables and removing them directly from the .env file.

Configuring Cloudflare R2

The Cloudflare R2 service is an Amazon S3 compatible provider, which means you can use the AWS SDK and bundle as is with one additional environment variable:

Replace <account_id> with the account ID found in the Cloudflare R2 dashboard; it's usually a 32 character hexadecimal string like 45242ae44b7b9f01930a43d617f9f7a8.

You'll also have to update the config/packages/aws.yaml file to use a different region and this environment variable. Change the region key from us-east-1 to auto, and add the endpoint key:

Using actions

This bundle registers a factory in the the Symfony container that will create a storage provider service object. Each storage provider service class implements a common interface: OneToMany\StorageBundle\Service\StorageServiceInterface. When a variable of this type is injected, the Symfony container will create the concrete storage provider service object defined by the STORAGE_SERVICE environment variable.

However, I do not recommend using the StorageServiceInterface directly. Instead, you should use an action class. There are two action classes:

Each of these expose a single public function, act(), which calls the actual StorageServiceInterface method to perform the action requested.

The code above would be rewritten as follows:

Action philosophy

The difference is subtle, but I prefer using the action classes for a few reasons:

  1. The class name indicates the action being performed: UploadFileAction clearly indicates that we're uploading a file.
  2. Any non-provider-specific pre or post-processing computation can be handled in the act() method rather than reimplementing it in each storage provider class.
  3. They can be mocked in tests easier. Because a concrete object is being injected, only the act() method needs to be mocked. Mocking (or creating an anonymous class of) an interface is more difficult and often overkill for a test that's only testing one codepath.

Credits

License

The MIT License


All versions of storage-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
ext-fileinfo Version *
psr/container Version ^2.0
psr/http-message Version ^2.0
symfony/dependency-injection Version ^7.2
symfony/filesystem Version ^7.2
symfony/http-kernel Version ^7.2
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 1tomany/storage-bundle contains the following files

Loading the files please wait ....