Download the PHP package codewiser/simple-files without Composer

On this page you can find all versions of the php package codewiser/simple-files. 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 simple-files

Simple lightweight storage

No database, only local filesystem.

Every model keeps its files isolated from each over. Path to files formed from model's morph name and its primary key.

Do not forget to enforceMorphMap in AppServiceProvider.

Define storage

Implement Attachmentable contract on Model.

In the example below the model will keep files on default disk at post/{id} path.

Uploading files

You may add files from UploadedFile, from local path or remote url. You may upload multiple files at once.

Removing files

File path attribute is a relative path to a disk, e.g. post/1/test.png. Use path attribute to delete file. You may delete multiple files at once.

To remove all files call flush method on Storage:

List files

To get collection with all files call files method on Storage:

Storage object is Arrayable too. It returns the same:

File object

File object has the same methods as Laravel Storage Facade: exists, size, lastModified, delete, checksum, url etc.

Every stored file represented with such array:

File object implements Responsable and Attachable, so you may use it as Response and in Notification or Mailable.

Singular Storage

Sometimes we need the model to have only one file. We may create such a storage:

When you upload next file to a storage, all previous files will be removed.

Singular storage has only one file, so files collection will contain only one element maximum. You may use file method instead.

Storage Pool

The model may have few storages at the same time. Storages must have unique names (aka buckets).

Then we may get the exact bucket:

Default storage

It is allowed to have one default storage in a pool:

Call storage without bucket name to get the default one.

Pool response

You may add a method to a model, that will return Pool object with all buckets defined:

Then you may use this method in api resource:

Pool toArray method will return an array with every bucket and its file(s). Singular storage provides file attribute, that may be null if no file were uploaded. Base storage provides files array, that may be empty.

Downloading files

The file is directly accessible only then published in public local filesystem. In other cases — private or cloud filesystem — application needs a controller to make files accessible to the users.

Let's say we have such private disk in config/filesystems.php:

If so, file url would be about private/post/1/test.png (for default bucket) or private/post/1/bucket/test.png (for named bucket).

We suggest to use a controller \Codewiser\Storage\StorageController, that is looks so:

All you need is to declare a route:


All versions of simple-files with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
laravel/framework Version >=10.0
league/flysystem Version ^3.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 codewiser/simple-files contains the following files

Loading the files please wait ....