Download the PHP package joredierckx/kirby-s3-sync without Composer

On this page you can find all versions of the php package joredierckx/kirby-s3-sync. 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 kirby-s3-sync

Kirby S3 Sync

[!NOTE] This is an early-stage release. Although core safeguards are in place, use it at your own risk. We strongly recommend creating backups before use.

Sync Kirby CMS files to S3 bucket/storage automatically, offloading local/server disk usage and serving assets through a CDN.

This plugin was originally inteded to work with Cloudflare's r2 storage, but since this is s3 compatible it works with all any S3-compatible storage.

Files uploaded through the Panel are pushed to your bucket, verified, and then replaced locally with a tiny placeholder — so your Kirby installation stays lightweight while the real files live on R2. file::url, file::version, and file::dimensions are transparently rerouted to the CDN, so templates and the Panel keep working without any changes to your existing code.

Built and maintained by Jore Dierckx.


Features


Requirements


Installation

Via Composer (recommended)


Configuration

Add the following to your site's config.php. Config options can be nested under an s3 key:

key and secret are your R2/S3 access credentials. These must never be hardcoded in config.php or committed to version control. Store the actual values in your site's .env file instead (which should be gitignored), and reference them via env() as shown above:

Kirby supports environment-specific config files (e.g. config/config.local.php), so s3.active can be set per environment — leaving it false on local/staging keeps development files on local disk (simpler to inspect and reset) and reserves bucket writes for production only.

Option reference

Option Required Description
s3.active Yes Master switch. When false, all hooks and API routes no-op and local files behave exactly as vanilla Kirby. Recommended: true only in production — keep it false on local/staging environments so development work doesn't write to your live bucket.
s3.key Yes Access key ID. Set via env('S3_KEY'), with the real value stored in .env — never hardcode this.
s3.secret Yes Secret access key. Set via env('S3_SECRET'), with the real value stored in .env — never hardcode this.
s3.bucket Yes Name of your S3-compatible bucket.
s3.region Yes Bucket region. Use auto for R2.
s3.endpoint Yes S3-compatible API endpoint URL.
s3.sitename Yes Namespace prefix for object keys (sitename/page-id/assets/...). Must be unique per site if multiple sites share one bucket, or files can collide. Avoid . in the value since it's used as a subdomain.
s3.cdn No Public CDN base URL. When set, enables Cloudflare Image Resizing URLs and JSON metadata fetching. Leave unset for providers without an equivalent (e.g. plain DigitalOcean Spaces).

How it works

On file create / replace

  1. File is uploaded to the bucket via putObject.
  2. Upload is verified with a doesObjectExist check.
  3. Image dimensions are read locally with getimagesize() — this doesn't depend on the CDN having finished processing the file yet.
  4. If s3.cdn is configured, Cloudflare's image-info JSON endpoint is fetched as supplementary metadata (file size, format, etc.). This step is skipped entirely on non-Cloudflare providers.
  5. s3_key, s3_json, s3_width, and s3_height are saved to the file's content file.
  6. Only after all of the above succeeds, the local file is replaced with a 1×1px placeholder.

If any step fails, the error is logged and the local file is left completely untouched — nothing is deleted or replaced on a failed upload.

On file delete

The object is copied to an _archive/ prefix in the same bucket before the original key is deleted — a soft-delete safety net. You can periodically clear out _archive/ manually once you're confident nothing needs recovering.

Serving files

Three of Kirby's core components are overridden:

Existing templates using $file->url(), $file->resize(), $file->crop(), etc. don't need any changes.


Blueprint fields

The plugin ships a reusable field group (blueprints/fields/s3meta.yml) that can be included in any file blueprint where you want these fields visible in the Panel — all are managed automatically and don't need to be editable:

The fields in the group are:

s3_json is intentionally left out of the group by default since it's raw metadata, not something editors need to see — but it's stored in the content file and can be added to the group the same way if useful for debugging.


REST API

A route is registered for programmatic uploads (e.g. from a custom Panel UI):

{pageId} should have any / characters replaced with +. Returns {"status": "ok"} on success, or {"status": "error", "message": "..."} on failure. Respects s3.active — returns an error if sync is disabled.


CLI scripts

Two standalone scripts are included in scripts/ for one-off and maintenance work outside the normal Panel flow. Both support --dry-run and prompt for confirmation before making any changes.

migrate-to-s3.php

Bulk-migrates existing local files to your bucket — intended for the initial move to R2, or for re-syncing after restoring a backup.

update-s3-meta.php

Backfills s3_width / s3_height (and s3_json) on files that were migrated before those fields existed, or after a plugin upgrade that adds new metadata fields.


Provider compatibility

This plugin works with any S3-compatible endpoint. Cloudflare-specific behavior (the JSON metadata fetch and Image Resizing URLs in file::version) is only active when s3.cdn is set — leave it unset when using a provider without an equivalent feature, and the plugin falls back to plain bucket URLs and locally-read dimensions.


Safety notes


Support

If this project saves you time, consider supporting it:

Buy Me A Coffee


License

MIT © Jore Dierckx


All versions of kirby-s3-sync with dependencies

PHP Build Version
Package Version
Requires getkirby/composer-installer Version ^1.1
aws/aws-sdk-php Version ^3.0
vlucas/phpdotenv Version ^5.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 joredierckx/kirby-s3-sync contains the following files

Loading the files please wait ...