Download the PHP package atk4/filestore without Composer

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

Starting from Version 1.4 of ATK UI, it adds support for File and Image uploads. In it's raw form, developer is responsible for taking care of the file once it's uploaded. In most cases, developer would want to store file either on a local or remote filesystem, but he would need to perform that action himself.

Filestore is a plugin for ATK Data and ATK UI which offers seamless integration with Flysystem.

Introduction

Attaching files to your database records is super-simple with Filestore. The next example can be implemented and added to YOUR php application in just a few lines:

Since ATK Form submits using AJAX file must be sent to the server as soon as it is selected. File is instantly placed inside flysystem (in the demo I'm using Local storage) and record in the database is created containing all the information about the file including if it is an image and if it is - dimensions:

Two random identifiers are generated - one is used for the actual file name (to make sure you don't overwrite existing file) and another one (token) will be used to reference the file. Actually you don't see a token at all, but it's used to keep things secure.

Files can be uploaded directly in your CRUD and you can have several file fields:

In your main table you only need one varchar field to store file token. If you use SQL, you can have instant access to additional fields such as name of original file or more:

This is especially valuable if you need to incorporate all these fields on your custom template.

Installation and Code

To install run composer require atk4\filestore and you will need to create filestore_file table. In the definition of your model, you simply need to declare a new field:

This pretty much takes care of everything! For full example see file demos/basic.php.

Features

Currently the following features are implemented:

Roadmap

We have the following ideas for the up-coming version. If you would like to help us implement (or sponsor) any of the features below, please contact @romaninsh (https://gitter.im/atk4/atk4):


OLD README:

event, so file upload will take place as soon as the file is selected. There are however some conditions, when file uploaded/deleted and form is not submitted.

On successful completion, PHP-side callback is executed to generate ID. Filestore provides this callback and performs the following actions:

Example

If you have a Model such as Friend and you wish to upload friend's photo, Filestore offers a great way to integrate:

This field will automatically appear on the form as an upload field, but in the database will be storing "token" from the "File" model. You can even define multiple fields like that.

By default the local file storage will be used, but you can configure a different location simply by passing into your field:

If you open form for the Friend which already have a file attached, you will be able to remove the files. However just "removing" files may not mean they will be unassociated, user can still click "Cancel". When form is saved, however, if the file was removed, it will be also deleted from the storage and from File table.

Image

Filestore also implements \Atk4\Filestore\Field\Image class which offers additional features by extending File to automatically crop and store various thumbnails for an image.

The cropping will maintain aspect ratio of original image, but will make sure that the image is filled. Will use either "imagick" or "gd" for the operation. Arguments are defined like that:

In order to store thumbnails, filestore will create additional file(s) inside File table.

File model

Filestore comes with a custom Model Atk4\Filestore\Model\File, which is designed to store file meta-information. For each uploaded file it stores:

Several "meta" fields are also defined which describe contents of the file

Methods

Create a File entity, save the data to flysystem and save the entity.

Returns stream of file contents. You can call $stream->getContents() to fetch the file content as a string.

Roadmap

Some of the possible future features:


All versions of filestore with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4 <8.4
atk4/ui Version ~5.0.0
league/flysystem Version ^2.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 atk4/filestore contains the following files

Loading the files please wait ....