{"id":15027165,"url":"https://github.com/teodoroleckie/versioned-assets","last_synced_at":"2026-02-15T01:34:11.960Z","repository":{"id":57070529,"uuid":"367101948","full_name":"teodoroleckie/versioned-assets","owner":"teodoroleckie","description":"⚡ Moving asset locations is cumbersome and error prone it requires you to carefully update the URLs of all assets included in all templates. The asset component allows you to have full control of the paths of your resources in an orderly way that is easy to maintain.","archived":false,"fork":false,"pushed_at":"2021-05-20T11:21:10.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T20:28:38.726Z","etag":null,"topics":["asset","asset-management","assets","assets-management","php","php-8","php8","versioned-asset","versioned-assets"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teodoroleckie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["teodoroleckie"],"custom":["https://www.paypal.com/donate?business=ZHYA2MTGA4884\u0026currency_code=USD"]}},"created_at":"2021-05-13T16:02:25.000Z","updated_at":"2023-04-13T02:12:57.000Z","dependencies_parsed_at":"2022-08-24T14:54:22.748Z","dependency_job_id":null,"html_url":"https://github.com/teodoroleckie/versioned-assets","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodoroleckie%2Fversioned-assets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodoroleckie%2Fversioned-assets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodoroleckie%2Fversioned-assets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodoroleckie%2Fversioned-assets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teodoroleckie","download_url":"https://codeload.github.com/teodoroleckie/versioned-assets/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243330319,"owners_count":20274039,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["asset","asset-management","assets","assets-management","php","php-8","php8","versioned-asset","versioned-assets"],"created_at":"2024-09-24T20:05:52.728Z","updated_at":"2026-02-15T01:34:06.941Z","avatar_url":"https://github.com/teodoroleckie.png","language":"PHP","funding_links":["https://github.com/sponsors/teodoroleckie","https://www.paypal.com/donate?business=ZHYA2MTGA4884\u0026currency_code=USD"],"categories":[],"sub_categories":[],"readme":"# versioned-assets\n# Fast and powerful php versioned-assets engine\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/teodoroleckie/versioned-assets/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/teodoroleckie/versioned-assets/?branch=main)\n[![Code Intelligence Status](https://scrutinizer-ci.com/g/teodoroleckie/versioned-assets/badges/code-intelligence.svg?b=main)](https://scrutinizer-ci.com/code-intelligence)\n[![Build Status](https://scrutinizer-ci.com/g/teodoroleckie/versioned-assets/badges/build.png?b=main)](https://scrutinizer-ci.com/g/teodoroleckie/versioned-assets/build-status/main)\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require tleckie/versioned-assets\n```\nMoving asset locations is cumbersome and error, prone - it requires you to carefully update the URLs of all assets included in all templates.\nThe asset component allows you to have full control of the paths of your resources in an orderly way that is easy to maintain.\n\n# Usage\n\n```php\n\u003c?php\n\nuse Tleckie\\Assets\\Bucket;\nuse Tleckie\\Assets\\Versioned\\Versioned;\n\n$bucket = new Bucket(new Versioned('v1'), '/path');\n\n// Relative path\n$bucket-\u003eurl('js/app.js');\n//result: /path/js/app.js?v1\n\n// Absolute path\n$bucket-\u003eurl('/js/app.js');\n//result: /js/app.js?v1\n```\n\nYou can also customize the format of your version by adding the second parameter to which a sprintf will be applied:\n```php\n\u003c?php\n\nuse Tleckie\\Assets\\Bucket;\nuse Tleckie\\Assets\\Versioned\\Versioned;\n\n$bucket = new Bucket(\n    new Versioned('v1', \"%s?custom-version=%s\"), \n    '/path'\n);\n\n// Relative path\n$bucket-\u003eurl('js/app.js');\n//result: /path/js/app.js?custom-version=v1\n\n// Absolute path\n$bucket-\u003eurl('/js/app.js');\n//result: /js/app.js?custom-version=v1\n```\n\nIf you need to include your assets to have a domain, you simply need to include the domain as the value of the path argument:\nWhen configuring a domain as a path, the resources included as relative and absolute will have the same result\n```php\n\u003c?php\n\nuse Tleckie\\Assets\\Bucket;\nuse Tleckie\\Assets\\Versioned\\Versioned;\n\n$bucket = new Bucket(\n    new Versioned('v1', '%s?version=%s'), \n    '//domain.cookieless.com'\n);\n\n// Relative path\n$bucket-\u003eurl('js/app.js');\n//result: //domain.cookieless.com/js/app.js?version=v1\n\n// Absolute path\n$bucket-\u003eurl('/js/app.js');\n//result: //domain.cookieless.com/js/app.js?version=v1\n```\n\n```php\n\u003c?php\n\nuse Tleckie\\Assets\\Bucket;\nuse Tleckie\\Assets\\Versioned\\Versioned;\n\n$bucket = new Bucket(\n    new Versioned('v1', '%2$s/%1$s'), \n    '//domain.cookieless.com'\n);\n\n// Version in path\n$bucket-\u003eurl('js/app.js');\n//result: //domain.cookieless.com/v1/js/app.js\n```\n\nYou can also use NullVersioned if you want to disable versioning for your assets.\n```php\n\u003c?php\n\nuse Tleckie\\Assets\\Bucket;\nuse Tleckie\\Assets\\Versioned\\NullVersioned;\n\n$bucket = new Bucket(\n    new NullVersioned(), \n    '//domain.cookieless.com'\n);\n\n// Relative path\n$bucket-\u003eurl('js/app.js');\n//result: //domain.cookieless.com/js/app.js\n```\n\nA popular strategy to manage asset versioning, which is used by tools such as Webpack, is to generate a JSON file mapping all source file names to their corresponding output file:\n```json\n{\n\"css/app.css\": \"build/css/app.af316426ea1d10021f3f17ce8031f93c2.css\",\n\"js/app.js\": \"build/js/app.56fa630905267b809161e71d0f8a0c017b.js\"\n}\n```\n\n```php\n\u003c?php\n\nuse Tleckie\\Assets\\Bucket;\nuse Tleckie\\Assets\\Versioned\\JsonManifestVersioned;\n$bucket = new Bucket(\n    new JsonManifestVersioned(__DIR__ .'/json/rev-manifest.json')\n);\n\n$bucket-\u003eurl('css/app.css');\n//result: build/css/app.af316426ea1d10021f3f17ce8031f93c2.css\n\n$bucket-\u003eurl('js/app.js');\n//result: build/js/app.56fa630905267b809161e71d0f8a0c017b.js\n```\n\n```php\n\u003c?php\n\nuse Tleckie\\Assets\\Bucket;\nuse Tleckie\\Assets\\Versioned\\JsonManifestVersioned;\n\n$bucket = new Bucket(\n    new JsonManifestVersioned(__DIR__ .'/json/rev-manifest.json'),\n    '//domain.cookieless.com'\n);\n\n$bucket-\u003eurl('css/app.css');\n//result: //domain.cookieless.com/build/css/app.af316426ea1d10021f3f17ce8031f93c2.css\n\n$bucket-\u003eurl('js/app.js');\n//result: //domain.cookieless.com/build/js/app.56fa630905267b809161e71d0f8a0c017b.js\n```\n### Custom versioning:\nYou can create your custom versioning class by implementing the VersionedInterface interface.\n\n\n\nThat's all! I hope this helps you ;)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteodoroleckie%2Fversioned-assets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteodoroleckie%2Fversioned-assets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteodoroleckie%2Fversioned-assets/lists"}