Download the PHP package passchn/cakephp-assets without Composer

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

Assets plugin for CakePHP

What the plugin does

This plugin helps you to manage backend Assets which can be of any filetype. Assets are saved in a non-public folder and are handled by an AssetsTable.

You can create AssetEntities with useful methods:

General methods

Image rendering

CSV preview

Alibi-properties for any model

Installation

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

The recommended way to install composer packages is:

Load the plugin:

Run the Migrations to create the plugin tables:

Now you should have an assets_assets and an assets_phinxlog table in your database.

Having issues? Check out this demo app or the single commits to see how to setup the plugin.

CakePHP Version Map

There is no version 1 of this plugin yet. To use it within your project, check the version map:

Plugin Version CakePHP Version
dev-cake3 CakePHP 3.x
^0 -> ^0.4 CakePHP 4.x
^0.5 CakePHP 5.x

Uploading Files

AssetsController

You can directly upload files using the AssetsController. By default, you can access the index, view, and edit-methods through an Admin prefix: your-app.test/admin/assets/assets

Use Alibi names

You can use the Assets table to upload files from any model, say you have a users table and need a user image:

  1. Create a field userimage_id in the users table as nullable char(36) (UUID).
  2. Run the migrations: bin/cake bake users
  3. Now you need to tell CakePHP that your Userimage is not a real Entity, but comes from the Assets.AssetsTable table:

This does not work anymore. The cakephp-bake plugin from version 2.8 onwards seems to detect that you don't actually have a userimages table and will not assume a belongsTo relation. You will have to write the code yourself or downgrade to version 2.7.

You can now put an upload field for your Userimage e.g. in templates/Users/edit.php:

In order for this to work, the relation should be set properly, e.g. through bin/cake bake users, so that CakePHP knows that your $user->userimage is an Asset Entity. Note that you have to contain Userimages in your Controller or Table's finder methods:

The AssetsTable does not know which model the uploaded file belongs to. You can use the title, description, or category field to keep track of that.

To do this, you can inject custom behaviors into the AssetsTable to hook into Event Handlers (e.g., set the title on beforeSave()), or to create custom finder methods, e.g. by your defined categories.

In your config file app.php, app_local.php, or app_assets.php, you can override the default settings and add custom Behaviors.

File manipulation

Images

If an Asset is an image (the MimeType starts with image/*), you can call

This returns an instance of the Assets\Utilities\ImageAsset class, which offers a wrapper API for ImagineImage.

For example, you can call:

This will generate a scaled version of your original file, converted to WebP, and return the relative path (in /webroot) to the file.

You might want to output html directly:

This will call the ImageAsset::__toString() method and will return HTML with your set class, an alt-parameter with the Asset's title and correct width and height params.

Image manipulation is done through Intervention with GD as default, but you can enable imagick through your app.php config.

Rendering of <picture> elements

Load the PictureHelper in your AppView.php:

In a template, pass an ImageAsset to the Helper as well as an array of widths and params:

Feedback, Bugs, and Feature Requests

This plugin was no plugin from the beginning and we are working on making it usable now among different CakePHP installations.

As this package is in early development as a plugin, we don't expect it to fit in for a lot of use cases right now.

If you have questions or problems with the plugin, open an Issue on GitHub.

You can also contact me via email: [email protected]

Packages this plugin uses

Besides CakePHP, the plugin depends on the following packages:


All versions of cakephp-assets with dependencies

PHP Build Version
Package Version
Requires ext-fileinfo Version *
intervention/image Version ^2.7.2
league/csv Version ^9.8
nette/utils Version ^3.2 || ^4.0.0
php Version >=8.0
cakephp/cakephp Version ^4.2.10
josegonzalez/cakephp-upload Version ^7.0.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 passchn/cakephp-assets contains the following files

Loading the files please wait ....