{"id":21068915,"url":"https://github.com/brandcom/cakephp-assets","last_synced_at":"2026-01-25T18:03:15.687Z","repository":{"id":38452193,"uuid":"450524425","full_name":"brandcom/cakephp-assets","owner":"brandcom","description":"Backend Asset Management for CakePHP","archived":false,"fork":false,"pushed_at":"2024-05-16T14:39:50.000Z","size":697,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"cake5","last_synced_at":"2025-10-12T07:47:54.955Z","etag":null,"topics":["cakephp","files","image-manipulation","image-resize","thumbnails","uploads","webp"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brandcom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-21T14:34:28.000Z","updated_at":"2024-04-03T07:03:26.000Z","dependencies_parsed_at":"2024-05-16T15:44:46.011Z","dependency_job_id":null,"html_url":"https://github.com/brandcom/cakephp-assets","commit_stats":{"total_commits":75,"total_committers":4,"mean_commits":18.75,"dds":"0.41333333333333333","last_synced_commit":"26cac826427040385a140139a2020d7bce068250"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/brandcom/cakephp-assets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandcom%2Fcakephp-assets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandcom%2Fcakephp-assets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandcom%2Fcakephp-assets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandcom%2Fcakephp-assets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brandcom","download_url":"https://codeload.github.com/brandcom/cakephp-assets/tar.gz/refs/heads/cake5","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandcom%2Fcakephp-assets/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28756432,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T16:32:25.380Z","status":"ssl_error","status_checked_at":"2026-01-25T16:32:09.189Z","response_time":113,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cakephp","files","image-manipulation","image-resize","thumbnails","uploads","webp"],"created_at":"2024-11-19T18:29:22.248Z","updated_at":"2026-01-25T18:03:15.670Z","avatar_url":"https://github.com/brandcom.png","language":"PHP","readme":"# Assets plugin for CakePHP\n\n## What the plugin does\n\nThis plugin helps you to manage backend Assets which can be of any filetype. Assets are \nsaved in a non-public folder and are handled by an AssetsTable. \n\nYou can create AssetEntities with useful methods:\n\n### General methods\n\n* Check if the uploaded file still is there: `$asset-\u003eexists() // true or false` \n* `$asset-\u003egetFileSizeInfo()` prints a human-readable filesize.\n* Get a link to the AssetsController::download() (Admin-prefixed): `$asset-\u003egetDownloadLink()`\n\n### Image rendering \n\n* Call `echo $asset-\u003egetImage()-\u003escaleWidth(350)-\u003etoWebP()-\u003eaddCSS('my-class')` to render a WebP-thumbnail as HTML. \n* The rendered image will be saved in `webroot/img/modified` depending on the modifications and passed options. \n* Pass your custom InterventionImage Filters through `ImageAsset::applyFilter()`\n* You can call any InterventionImage API method through `ImageAsset::modify()`\n\n### CSV preview \n\n* You can use the `TextAssetPreviewHelper` to render tables from CSV-files. \n* Loop through rows in a csv-Asset: `foreach ($asset-\u003egetReader()-\u003egetRecords() as $row) ...`\n\n### Alibi-properties for any model\n\n* `$asset` can be `$user-\u003eimage`, `$company-\u003elogo` or your latest CSV import. Just configure a `belongsTo` relation on your model and set the ClassName.\n\n## Installation\n\nYou can install this plugin into your CakePHP application using [composer](https://getcomposer.org).\n\nThe recommended way to install composer packages is:\n\n```\ncomposer require passchn/cakephp-assets\n```\n\nLoad the plugin: \n```\n bin/cake plugin load Assets\n```\n\nRun the Migrations to create the plugin tables: \n```\nbin/cake migrations migrate -p Assets\n```\n\nNow you should have an `assets_assets` and an `assets_phinxlog` table in your database. \n\n\u003e Having issues? Check out [this demo app](https://github.com/passchn/cakephp-assets-example-app/) or the [single commits](https://github.com/passchn/cakephp-assets-example-app/commits/main) to see how to setup the plugin. \n\n## CakePHP Version Map\n\nThere is no version 1 of this plugin yet. To use it within your project, check the version map: \n\n| Plugin Version | CakePHP Version | \n| ---------------| ----------------|\n| dev-cake3      | CakePHP 3.x     |\n| ^0 -\u003e ^0.4     | CakePHP 4.x     |\n| ^0.5           | CakePHP 5.x     |\n\n## Uploading Files\n\n### AssetsController\n\nYou can directly upload files using the AssetsController. By default, you can access\nthe index, view, and edit-methods through an `Admin` prefix: `your-app.test/admin/assets/assets` \n\n### Use Alibi names \n\nYou can use the Assets table to upload files from any model, say you have a `users` table\nand need a user image:\n1. Create a field `userimage_id` in the `users` table as nullable `char(36)` (UUID).\n2. Run the migrations: `bin/cake bake users`\n3. Now you need to tell CakePHP that your `Userimage` is not a real Entity, but comes from the `Assets.AssetsTable` table: \n\n```\nin \\App\\Model\\Table\\Users: \n\n$this-\u003ebelongsTo('Userimages')\n    -\u003esetForeignKey('userimage_id')\n    -\u003esetClassName('Assets.Assets');\n```\n\u003e 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`. \n\nYou can now put an upload field for your Userimage e.g. in `templates/Users/edit.php`: \n```\n\u003c?= $this-\u003eForm-\u003ecreate($user, ['type' =\u003e 'file']) ?\u003e\n    ...\n    ...\n    \u003c?= $this-\u003eForm-\u003econtrol('userimage.filename', [\n        'type' =\u003e 'file', \n        'label' =\u003e 'Upload a profile photo',\n    ]) ?\u003e\n    ...\n\u003c?= $this-\u003eForm-\u003eend() ?\u003e\n```\n\nIn order for this to work, the relation should be set properly, e.g. through `bin/cake bake users`, so that \nCakePHP knows that your `$user-\u003euserimage` is an `Asset` Entity. Note that you have to contain\n`Userimages` in your Controller or Table's finder methods: \n\n```\n$users = $this-\u003eUsers-\u003efind()-\u003econtain([\n        'Userimages',\n        'Addresses,\n        '...\n    ]);\n    \n$image = $users-\u003efirst()-\u003euserimage?-\u003egetImage();\n```\n\nThe 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. \n\nTo 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. \n\nIn your config file `app.php`, `app_local.php`, or `app_assets.php`, you can override the [default settings](https://github.com/passchn/cakephp-assets/blob/master/config/app_assets.php) and add custom Behaviors.\n\n## File manipulation \n\n### Images \n\nIf an Asset is an image (the MimeType starts with `image/*`), you can call \n```\n$asset-\u003egetImage(); \n```\n\nThis returns an instance of the `Assets\\Utilities\\ImageAsset` class, which offers a wrapper API for `ImagineImage`. \n\nFor example, you can call: \n```\necho $asset-\u003egetImage()-\u003escaleWidth(350)-\u003etoWebP()-\u003egetPath()\n```\n\nThis will generate a scaled version of your original file, converted to WebP, and return the relative path (in `/webroot`) to the file. \n\nYou might want to output html directly: \n\n```\n\u003c?= $asset-\u003egetImage()-\u003escaleWidth(520)-\u003etoJpg()-\u003esetCSS('my-class') ?\u003e\n```\n\nThis will call the `ImageAsset::__toString()` method and will return HTML with your set class,\nan alt-parameter with the Asset's title and correct `width` and `height` params. \n\nImage manipulation is done through Intervention with GD as default, but you can enable imagick through your app.php config. \n\n#### Rendering of `\u003cpicture\u003e` elements\n\nLoad the PictureHelper in your `AppView.php`: \n```\n$this-\u003eloadHelper('Assets.Picture');\n```\nIn a template, pass an `ImageAsset` to the Helper as well as an array of widths and params:  \n\n```\n\u003c?= $this-\u003ePicture-\u003ewebp(\n    $user-\u003ephoto-\u003emodify('resize', 350, 600),\n    [150, 350],\n    [\n        'class' =\u003e 'user-img',\n        'width' =\u003e 350,\n        'height' =\u003e 600,\n        'sizes' =\u003e \"(min-width: 230px) 100vw, (min-width: 640px) 50vw\"\n    ]\n) ?\u003e\n```\n\n## Feedback, Bugs, and Feature Requests\n\nThis plugin was no plugin from the beginning and we are working on making it usable now among different CakePHP installations. \n\nAs 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.  \n\nIf you have questions or problems with the plugin, open an Issue on GitHub.  \n\nYou can also contact me via email:\n[post@pascalschneider.eu](mailto:post@pascalschneider.eu)\n\n## Packages this plugin uses\n\nBesides CakePHP, the plugin depends on the following packages: \n```\n\"josegonzalez/cakephp-upload\": \"^6.0\",\n\"league/csv\": \"^9.8\",\n\"nette/utils\": \"^3.2 || ^4.0\",\n\"intervention/image\": \"^2.7\"\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandcom%2Fcakephp-assets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrandcom%2Fcakephp-assets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandcom%2Fcakephp-assets/lists"}