{"id":20253160,"url":"https://github.com/becklyn/assetsbundle","last_synced_at":"2025-04-10T23:33:11.072Z","repository":{"id":30903038,"uuid":"34460830","full_name":"Becklyn/AssetsBundle","owner":"Becklyn","description":"High-performance asset handling for symfony projects.","archived":false,"fork":false,"pushed_at":"2023-01-13T16:10:54.000Z","size":508,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"2.x","last_synced_at":"2025-04-08T11:17:45.133Z","etag":null,"topics":["php","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Becklyn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2015-04-23T14:21:03.000Z","updated_at":"2022-02-17T11:02:59.000Z","dependencies_parsed_at":"2023-01-14T17:55:19.661Z","dependency_job_id":null,"html_url":"https://github.com/Becklyn/AssetsBundle","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Becklyn%2FAssetsBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Becklyn%2FAssetsBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Becklyn%2FAssetsBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Becklyn%2FAssetsBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Becklyn","download_url":"https://codeload.github.com/Becklyn/AssetsBundle/tar.gz/refs/heads/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317055,"owners_count":21083515,"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":["php","symfony","symfony-bundle"],"created_at":"2024-11-14T10:21:46.942Z","updated_at":"2025-04-10T23:33:11.054Z","avatar_url":"https://github.com/Becklyn.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"BecklynAssetsBundle\n===================\n\nHigh-performance asset handling for symfony projects.\n\nThis bundle is a simplified and specialized replacement for `symfony/asset`.\n\n\nInstallation\n------------\n\n```bash\ncomposer require \"becklyn/assets-bundle\"\n```\n\nand then add the bundle in your `AppKernel` / `bundles.php`.\n\nLoad the routes (preferably only in `dev`):\n\n```yaml\nbecklyn_assets:\n    resource: \"@BecklynAssetsBundle/Resources/config/routes.yaml\"\n    prefix: /\n```\n\nTo use the static compression of assets, install `zopfli` or `gzip`.\n\n```bash\napt install zopfli\n# or\nbrew install zopfli\n```\n\n\nInfo / Purpose\n--------------\n\nThis bundle aims to provide a way to transparently handle long-term caching of assets.\n\nAll assets in your entry points are copied (and possibly transformed) to `public/assets/` and the file names modified, so that they contain the content hash of the given file.\nIt also provides Twig functions to use these translated paths transparently in a symfony application.\n\nIn Twig the original filename is given to the `asset*` function and it automatically generates the HTML reference for the hashed file name.\n\n**Warning:** the directory `public/assets/` is completely cleared on cache clear, so it should exclusively be managed by this bundle.\n\nAll requests to the `assets/` directory can be cached for a long time, like with a expiry date in the far future or even `immutable` headers.\n\n\nUsage\n-----\n\nThe asset generation and preparation is done automatically.\nThe assets are pregenerated on cache clear + warmup or on-the-fly generated if encountered with an empty cache.\n\nIn the configuration a mapping of namespaces to directories is defined. These namespaces are then used to retrieve paths to these files by using the `@{namespace}/{path}` syntax:\n\n```yaml\nbecklyn_assets:\n    entries:\n        bundles: \"public/bundles\"\n```\n\nIn Twig, the following functions can be used:\n\n```twig\n{# automatically generates the \u003cscript\u003e\u003c/script\u003e tags #}\n{{ assets_js([\n    \"@bundles/app/js/bootstrap.js\",\n    \"@bundles/app/js/app.js\",\n]) }}\n\n{# automatically generates the \u003clink\u003e tags #}\n{{ assets_js([\n    \"@bundles/app/css/bootstrap.css\",\n    \"@bundles/app/css/app.css\",\n]) }}\n\n{# just returns the URL #}\n\u003cimg src=\"{{ asset(\"@bundles/app/img/logo.svg\") }}\" alt=\"Company Logo\"\u003e\n```\n\n\nAsset Processing\n----------------\n\nCurrently only one asset processor is included in the bundle. Asset processors are chosen by file extension and are supposed to transform the given file content.\nThey are not supposed to alter the file in terms of minification, but to adjust import paths (like `url(...)` in CSS) to the new paths.\n\nCurrently registered processors:\n\n| Processor      | File Extensions | Purpose                   |\n| -------------- | --------------- | ------------------------- |\n| `CssProcessor` | `.css`          | Rewrite `url(...)` paths. |\n\n\n**Warning:**\nThe asset processors are using the paths from the `AssetCache`. This implies a race condition, as the processor can only rewrite paths of files that were already added to the cache. So files with a processor are deferred and only processed after all other files are finished (at least if the command / cache warmer is used). There still can be race conditions, if files with processors depend on each other. \n\n\nConfiguration\n-------------\n\nAll configuration values with their description and defaults:\n\n```yaml\nbecklyn_assets:\n    # the entry points. Maps the namespace to the directory (relative to `%kernel.project_dir%`)\n    # -\u003e is required\n    entries:\n        bundles: \"public/bundles\"\n        app: \"assets\"\n        \n    # the absolute path to the `public/` (or `web/`) directory\n    public_path: '%kernel.project_dir%/public' \n    # relative path to the directory, where the assets are copied to (relative to `public_path`)\n    output_dir: 'assets' \n    # allow crossorigin assets e.g needed for basic auth if using safari browser\n    allow_cors: true\n```\n\nCommands\n--------\n\n### `becklyn:assets:reset`\n\nThe bundle provides a command to clear and warmup the cache:\n\n```bash\n# clear + warmup\nphp bin/console becklyn:assets:reset\n\n# only clear\nphp bin/console becklyn:assets:reset --no-warmup\n``` \n\nNormally these commands are not required, as the bundle automatically registers as **cache clearer** and **cache warmer**.\n\n\n### `becklyn:assets:namespaces`\n\nThis command prints an overview over all registered namespaces.\nThis is especially useful if you register paths programmatically outside of your configuration.\n\n\n## nginx Integration\n\nYour project can cache the dumped assets indefinitely, as the file names are derived from the content.\n\n```nginx\nlocation /assets {\n    add_header Cache-Control \"public, max-age=31536000, immutable\";\n    add_header Vary \"Accept-Encoding\";\n    log_not_found off;\n    \n    # only activate if it is supported\n    gzip_static on;\n    \n    # be sure to add all security headers (like X-Frame-Options and HSTS or X-Content-Type-Options here as well)    \n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbecklyn%2Fassetsbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbecklyn%2Fassetsbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbecklyn%2Fassetsbundle/lists"}