Download the PHP package nvahalik/laravel-filer without Composer

On this page you can find all versions of the php package nvahalik/laravel-filer. 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-filer

Laravel Filer

This project was started to scratch my itch on our growing Laravel site:

Getting Started

To get started, require the project.

Laravel 7, 8 (Flysystem V1):

composer require nvahalik/laravel-filer@^1

Laravel 9 (Flysystem V3):

composer require nvahalik/laravel-filer@dev-laravel-9

Once that's done, you'll need to edit the filer config file and then update your filesystem configuration.

Config File

By default, the metadata is stored in a JSON file. You can edit config/filer.php to change the default storage mechanism from json to database or memory. Note that memory is really a null adapter. The JSON adapter wraps memory and just serializes and saves it after each operation.

Filesystem Configuration

The configuration is very similar to other disks:

'example' => [
    'driver' => 'filer',
    'original_disks' => [
        'test:s3-original',
    ],
    'id' => 'test',
    'disk_strategy' => 'basic',
    'backing_disks' => [
        'test:s3-new',
        'test:s3-original',
    ],
    'visibility' => 'private',
],

The original_disks is an option if you are migrating from an existing disk or disks to the filer system. Effectively, this is a fallback so that files which are not found in the local metadata store will be searched for in original_disks. If they are found, their metadata will be imported. If not, the file will be treated as missing. We'll cover doing mass importing of metadata later on.

Note: that this will slow the filesystem down until the cache is filled. Once the cache is loaded, you can remove these original_disks and those extra operations looking for files will be eliminated.

Note 2: files which are truly missing do not get cached. Therefore, if a file is missing, and you repeatedly attempt to assert its existence, it will search over and over again. This could be improved by caching the results or likewise having some sort of missing-files cache.

id is just an internal ID for the metadata store. File duplications are not allowed within the metadata of a single id, for example, but would be allowed for different ids.

disk_strategy has only a single option currently: 'basic' but will be pluggable to allow for different strategies to be added and used. The basic strategy simply writes to the first available disk from the list of provided backing_disks.

backing_disks allows you to define multiple flysystem disks to use. Want to use multiple S3-compatible adapters? You can. Note that for the basic adapter, the order of the disks determines the order in which they are tried.

A couple of examples

Given the configuration above, if the following code is run:

  1. The existing metadata repo will be searched.
  2. Then, the single 'original_disks' will be searched.
  3. Finally, the operation will fail.

  4. The existing metadata repo will be searched.
  5. Then, the single 'original_disks' will be searched.
  6. Then, a write will be attempted on test:s3-new.
  7. If that fails, then a write will be attempted on test:s3-original.
  8. If any of the writes succeeds, that adapter's backing information will be returned and the entries metadata updated.
  9. If any of them fails, then false will be returned and the operation will have failed.

Importing Metadata

If you already have a ton of files on S3, you can use the filer:import-s3-metadata command to import that data into your metadata repository:

The importer uses File::lines() to load its data, and therefore should not consume a lot of memory. Additionally, it will look at the bucket name in the URL which is present in the output and attempt to find that within your existing filesystems config.

Visibility

By default, it will grab this from the filesystem configuration. If none is found nor provided with --visibility, it will default to private.

Filename stripping

You can strip a string from the filenames by specifying the --strip option.

Disk

If you need to specify the disk directly or want to otherwise override it, just pass it in with --disk. This is not checked, so don't mess it up.

Example

The above command would strip prefix-dir/ from the imported URLs, set their visibility to public, and mark their default backing-disk to some-disk.


All versions of laravel-filer with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
illuminate/database Version ^8.2
illuminate/support Version ^8.2
league/flysystem Version ^1
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 nvahalik/laravel-filer contains the following files

Loading the files please wait ....