Download the PHP package josbeir/cakephp-filesystem without Composer

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

Build Status codecov Latest Stable Version Total Downloads

Filesystem plugin for CakePHP

CakePHP filesystem plugin using Flysystem as it's backend.

Why

Requirements

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

Configuration

A filesystem configuration array should be available in your Configure instance. You can create a config/filesystems.php file with following content Make sure to load the file in your bootstrap.php using .

The configuration options defined for each 'filestem' are passed directly to the Filesystem.php class. A default configuration must be set when using FilesystemAwareTrait / FilesystemRegistry classes

Simple upload example

Filesystem instances can be accessed from everywhere where you either use the FilesystemAwareTrait and calling or the

In this example we are using a fictive 'myfs' filesystem definition, if you leave that empty the default FS will be used when calling getFilesystem().

Upload data submitted in POST:

Example controller:

Result

The result from the above example will output a file entity class

Entity properties

A JsonSerializable FileEntity ArrayObject is returned when the file was successfully uploaded. Properties can be accessed, checked and manipulated using get and set and has**

Calling json_encode on the entity

Recreating entities

If you for instance saved a file entity somwhere as a json object you could recreate the entity using Filemanager::newEntity

Recreating a Collection of entities.

Using your own entities

Creating your own entities is possible by implementing the FileEntityInterface class and setting the entity class FQCN in your configuration's entityClass key.

Example on using Cake ORM entities instead of the built entity class

If you want to store your entities in the ORM you can easily swap the entity class with an ORM one. The only requirement is that the entity implements the FileEntityInterface class.

Then make sure your ORM entity implements the FileEntityInterface and its required method 'getPath':

Now when uploading and using files you can work with ORM entities.

Formatters

During upload a formatter is used to construct a path and filename. For instance, if you use the EntityFormatter you can use variables available in an entity to build the filename.

The default EntityFormatter pattern is {entity-source}/{file-name}.{file-ext} which results in posts/myfile.png

Setting up formatters

Formatters are simple classes used to name and clean file paths during upload, this plugin currently comes with two formatters.

Should result in something like posts/2018-05-26-myfile-key.png .

Creating a custom formatter class

Creating your own formatter class is pretty straightforward. The class should implement FormatterInterface Check the DefaultFormatter or EntityFormatterclasses for more information.

Example custom formatter

Using the custom formatter class in your application

The formatter FQCN can be set in the filesystem config or whenever you call setFormatter.

Methods

The Filesystem class itself implements a few convenience methods around the Flysystem filesystem class.

Other methods are proxied over. If you wish to use the Flysystem instance directly then please use getDisk().

Events

Events are dispatched when performing an operation on a file entity. Currently the following events are implemented:

Name Passed params Stoppable?
Filesystem.beforeUpload FileSource, Formatter No
Filesystem.afterUpload FileEntity, FileSource No
Filesystem.beforeDelete FileEntity Yes
Filesystem.afterDelete FileEntity No
Filesystem.beforeRename FileEntity, new path Yes
Filesystem.afterRename FileEntity No
Filesystem.beforeCopy FileEntity, destination path Yes
Filesystem.afterCopy (new) FileEntity, (old) FileEntity No

Extras

Changing the hashing algorithm used in entities

Options can be passed to the FileSourceNormalizer using the 'normalizer' parameter in the filesystem instance config:

Accessing the Flysytem object

Because this plugin is using flysystem at its core one could easily integrate with other flysystem compatible code. Accessing the flysystem directly can be done using Filesystem::getDisk().

As an example we can work with Admad's glide plugin and use configured filesystems as source and cache:

First set up your default and cache configurations:

Then set up the Glide middleware using the configured filesystems mentioned above:

Contribute

Before submitting a PR make sure:


All versions of cakephp-filesystem with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0.2
cakephp/cakephp Version ^4.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 josbeir/cakephp-filesystem contains the following files

Loading the files please wait ....