{"id":20267109,"url":"https://github.com/rapsys/packbundle","last_synced_at":"2025-03-03T22:12:01.594Z","repository":{"id":212128709,"uuid":"544682268","full_name":"rapsys/packbundle","owner":"rapsys","description":"Symfony bundle rapsys/packbundle used to compress ressources","archived":false,"fork":false,"pushed_at":"2024-12-08T07:05:13.000Z","size":206,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-14T05:14:05.603Z","etag":null,"topics":["assetic","assetic-bundle","assetic-filters","captcha","facebook","image","image-processing","imagemagick","jpeg","openstreetmap","osm","php","png","slugger","symfony","symfony-bundle","webp","webpack","webpacker"],"latest_commit_sha":null,"homepage":"https://git.rapsys.eu/packbundle/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rapsys.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-10-03T03:15:46.000Z","updated_at":"2024-12-08T07:05:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"e61b814a-0ec7-4488-859f-a5a04139e792","html_url":"https://github.com/rapsys/packbundle","commit_stats":null,"previous_names":["rapsys/packbundle"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapsys%2Fpackbundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapsys%2Fpackbundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapsys%2Fpackbundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapsys%2Fpackbundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rapsys","download_url":"https://codeload.github.com/rapsys/packbundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241746798,"owners_count":20013165,"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":["assetic","assetic-bundle","assetic-filters","captcha","facebook","image","image-processing","imagemagick","jpeg","openstreetmap","osm","php","png","slugger","symfony","symfony-bundle","webp","webpack","webpacker"],"created_at":"2024-11-14T12:13:16.852Z","updated_at":"2025-03-03T22:12:01.576Z","avatar_url":"https://github.com/rapsys.png","language":"PHP","readme":"Contribute\n==========\n\nYou may buy me a Beer, a Tea or help with Server fees with a paypal donation to\nthe address \u003cpaypal@rapsys.eu\u003e.\n\nDon't forget to show your love for this project, feel free to report bugs to\nthe author, issues which are security relevant should be disclosed privately\nfirst.\n\nPatches are welcomed and grant credit when requested.\n\nInstallation\n============\n\nApplications that use Symfony Flex\n----------------------------------\n\nAdd bundle custom repository to your project's `composer.json` file:\n\n```json\n{\n\t...,\n\t\"repositories\": [\n\t\t{\n\t\t\t\"type\": \"package\",\n\t\t\t\"package\": {\n\t\t\t\t\"name\": \"rapsys/packbundle\",\n\t\t\t\t\"version\": \"dev-master\",\n\t\t\t\t\"source\": {\n\t\t\t\t\t\"type\": \"git\",\n\t\t\t\t\t\"url\": \"https://git.rapsys.eu/packbundle\",\n\t\t\t\t\t\"reference\": \"master\"\n\t\t\t\t},\n\t\t\t\t\"autoload\": {\n\t\t\t\t\t\"psr-4\": {\n\t\t\t\t\t\t\"Rapsys\\\\PackBundle\\\\\": \"\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"require\": {\n\t\t\t\t\t\"symfony/asset\": \"^4.0|^5.0|^6.0|^7.0\",\n\t\t\t\t\t\"symfony/flex\": \"^1.0|^2.0\",\n\t\t\t\t\t\"symfony/framework-bundle\": \"^4.0|^5.0|^6.0|^7.0\",\n\t\t\t\t\t\"symfony/process\": \"^4.0|^5.0|^6.0|^7.0\",\n\t\t\t\t\t\"symfony/twig-bundle\": \"^4.0|^5.0|^6.0|^7.0\"\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t],\n\t...\n}\n```\n\nThen open a command console, enter your project directory and execute:\n\n```console\n$ composer require rapsys/packbundle dev-master\n```\n\nApplications that don't use Symfony Flex\n----------------------------------------\n\n### Step 1: Download the Bundle\n\nOpen a command console, enter your project directory and execute the\nfollowing command to download the latest stable version of this bundle:\n\n```console\n$ composer require rapsys/packbundle dev-master\n```\n\nThis command requires you to have Composer installed globally, as explained\nin the [installation chapter](https://getcomposer.org/doc/00-intro.md)\nof the Composer documentation.\n\n### Step 2: Enable the Bundle\n\nThen, enable the bundle by adding it to the list of registered bundles\nin the `app/AppKernel.php` file of your project:\n\n```php\n\u003c?php\n// app/AppKernel.php\n\n// ...\nclass AppKernel extends Kernel\n{\n\tpublic function registerBundles()\n\t{\n\t\t$bundles = array(\n\t\t\t// ...\n\t\t\tnew Rapsys\\PackBundle\\RapsysPackBundle(),\n\t\t);\n\n\t\t// ...\n\t}\n\n\t// ...\n}\n```\n\n### Step 3: Configure the Bundle\n\nSetup configuration file `config/packages/rapsys_pack.yaml` with the following\ncontent available in `Resources/config/packages/rapsys_pack.yaml`:\n\n```yaml\n#Services configuration\nservices:\n    #Replace assets.packages definition\n    assets.packages:\n        class: 'Symfony\\Component\\Asset\\Packages'\n        arguments: [ '@rapsys_pack.path_package' ]\n    #Replace assets.context definition\n    assets.context:\n        class: 'Rapsys\\PackBundle\\Context\\RequestStackContext'\n        arguments: [ '@request_stack', '%asset.request_context.base_path%', '%asset.request_context.secure%' ]\n    #Register assets pack package\n    rapsys_pack.path_package:\n        class: 'Rapsys\\PackBundle\\Package\\PathPackage'\n        arguments: [ '/', '@assets.empty_version_strategy', '@assets.context' ]\n        public: true\n    #Register twig pack extension\n    rapsys_pack.pack_extension:\n        class: 'Rapsys\\PackBundle\\Extension\\PackExtension'\n        arguments: [ '@service_container', '@rapsys_pack.intl_util', '@file_locator', '@rapsys_pack.path_package', '@rapsys_pack.slugger_util' ]\n        tags: [ 'twig.extension' ]\n    #Register intl util service\n    rapsys_pack.intl_util:\n        class: 'Rapsys\\PackBundle\\Util\\IntlUtil'\n        public: true\n    #Register facebook event subscriber\n    Rapsys\\PackBundle\\Subscriber\\FacebookSubscriber:\n        arguments: [ '@router', [] ]\n        tags: [ 'kernel.event_subscriber' ]\n    #Register intl util class alias\n    Rapsys\\PackBundle\\Util\\IntlUtil:\n        alias: 'rapsys_pack.intl_util'\n    #Register facebook util service\n    rapsys_pack.facebook_util:\n        class: 'Rapsys\\PackBundle\\Util\\FacebookUtil'\n        arguments: [ '@router', '%kernel.project_dir%/var/cache', '%rapsys_pack.path%' ]\n        public: true\n    #Register facebook util class alias\n    Rapsys\\PackBundle\\Util\\FacebookUtil:\n        alias: 'rapsys_pack.facebook_util'\n    #Register image util service\n    rapsys_pack.image_util:\n        class: 'Rapsys\\PackBundle\\Util\\ImageUtil'\n        arguments: [ '@router', '@rapsys_pack.slugger_util', '%kernel.project_dir%/var/cache', '%rapsys_pack.path%' ]\n        public: true\n    #Register image util class alias\n    Rapsys\\PackBundle\\Util\\ImageUtil:\n        alias: 'rapsys_pack.image_util'\n    #Register map util service\n    rapsys_pack.map_util:\n        class: 'Rapsys\\PackBundle\\Util\\MapUtil'\n        arguments: [ '@router', '@rapsys_pack.slugger_util' ]\n        public: true\n    #Register map util class alias\n    Rapsys\\PackBundle\\Util\\MapUtil:\n        alias: 'rapsys_pack.map_util'\n    #Register slugger util service\n    rapsys_pack.slugger_util:\n        class: 'Rapsys\\PackBundle\\Util\\SluggerUtil'\n        arguments: [ '%kernel.secret%' ]\n        public: true\n    #Register slugger util class alias\n    Rapsys\\PackBundle\\Util\\SluggerUtil:\n        alias: 'rapsys_pack.slugger_util'\n    #Register image controller\n    Rapsys\\PackBundle\\Controller\\ImageController:\n        arguments: [ '@service_container', '@rapsys_pack.image_util', '@rapsys_pack.slugger_util', '%kernel.project_dir%/var/cache', '%rapsys_pack.path%' ]\n        tags: [ 'controller.service_arguments' ]\n    #Register map controller\n    Rapsys\\PackBundle\\Controller\\MapController:\n        arguments: [ '@service_container', '@rapsys_pack.map_util', '@rapsys_pack.slugger_util', '%kernel.project_dir%/var/cache', '%rapsys_pack.path%' ]\n        tags: [ 'controller.service_arguments' ]\n    Rapsys\\PackBundle\\Form\\CaptchaType:\n        arguments: [ '@rapsys_pack.image_util', '@rapsys_pack.slugger_util', '@translator' ]\n        tags: [ 'form.type' ]\n```\n\nSetup configuration file `config/packages/myproject.yaml` with the following\ncontent available in `Resources/config/packages/rapsys_pack.yaml`:\n\n```yaml\n#Services configuration\nservices:\n    #Register facebook event subscriber\n    Rapsys\\PackBundle\\Subscriber\\FacebookSubscriber:\n        arguments: [ '@router', [ 'en', 'en_gb', 'en_us', 'fr', 'fr_fr' ] ]\n        tags: [ 'kernel.event_subscriber' ]\n    #Register facebook util service\n    rapsys_blog.facebook_util:\n        class: 'Rapsys\\PackBundle\\Util\\FacebookUtil'\n        arguments: [ '@router',  '%kernel.project_dir%/var/cache', '%rapsys_pack.path%', 'facebook', '%kernel.project_dir%/public/png/facebook.png' ]\n        public: true\n```\n\nOpen a command console, enter your project directory and execute the following\ncommand to see default bundle configuration:\n\n```console\n$ bin/console config:dump-reference RapsysPackBundle\n```\n\nOpen a command console, enter your project directory and execute the following\ncommand to see current bundle configuration:\n\n```console\n$ bin/console debug:config RapsysPackBundle\n```\n\n### Step 4: Use the twig extension in your Template\n\nYou can use a template like this to generate your first `rapsys_pack` enabled\ntemplate:\n\n```twig\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\t\u003chead\u003e\n\t\t\u003cmeta charset=\"UTF-8\" /\u003e\n\t\t\u003ctitle\u003e{% block title %}Welcome!{% endblock %}\u003c/title\u003e\n\t\t{% stylesheet '//fonts.googleapis.com/css?family=Irish+Grover|La+Belle+Aurore' '@NamedBundle/Resources/public/css/{reset,screen}.css' '@Short/css/example.css' %}\n\t\t\t\u003clink rel=\"stylesheet\" type=\"text/css\" href=\"{{ asset_url }}\" /\u003e\n\t\t{% endstylesheet %}\n\t\u003c/head\u003e\n\t\u003cbody\u003e\n\t\t{% block body %}{% endblock %}\n\t\t{% javascript '@Short/js/*.js' %}\n\t\t\t\u003cscript type=\"text/javascript\" src=\"{{ asset_url }}\"\u003e\u003c/script\u003e\n\t\t{% endjavascript %}\n\t\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Step 5: Make sure you have local binary installed\n\nYou need to have cpack and jpack scripts from https://git.rapsys.eu/packer/ repository\nset as executable and installed in /usr/local/bin.\n\nTo install cpack and jpack required packages open a root console and execute the\nfollowing command:\n\n```console\n# urpmi perl-base perl-CSS-Packer perl-JavaScript-Packer\n```\n\nor stone age distributions:\n\n```console\n# apt-get install libcss-packer-perl libjavascript-packer-perl\n```\n\nor other distributions through cpan:\n\n```console\n# cpan App::cpanminus\n# cpanm CSS::Packer\n# cpanm JavaScript::Packer\n```\n\n### Step 6: Create your own filter\n\nYou can create you own mypackfilter class which call a mypack binary:\n\n```php\n\u003c?php\n\nnamespace Rapsys\\PackBundle\\Filter;\n\nuse Twig\\Error\\Error;\n\n//This class will be defined in the parameter rapsys_pack.filters.(css|img|js).[x].class string\nclass MyPackFilter implements FilterInterface {\n\t//The constructor arguments ... will be replaced with values defined in the parameter rapsys_pack.filters.(css|img|js).[x].args array\n\tpublic function __construct(string $fileName, int $line, string $bin = 'mypack', ...) {\n\t\t//Set fileName\n\t\t$this-\u003efileName = $fileName;\n\n\t\t//Set line\n\t\t$this-\u003eline = $line;\n\n\t\t//Set bin\n\t\t$this-\u003ebin = $bin;\n\n\t\t//Check argument presence\n\t\tif (!empty($this-\u003e...)) {\n\t\t\t//Append argument\n\t\t\tif ($this-\u003e... == '...') {\n\t\t\t\t$this-\u003ebin .= ' ...';\n\t\t\t} else {\n\t\t\t\t//Throw an error on ...\n\t\t\t\tthrow new Error(sprintf('Got ... for %s: %s', $this-\u003ebin, $this-\u003e...), $this-\u003eline, $this-\u003efileName);\n\t\t\t}\n\t\t}\n\t}\n\n\t//Pass merge of all inputs in content\n\tpublic function process(string $content): string {\n\t\t//Create descriptors\n\t\t$descriptorSpec = array(\n\t\t\t0 =\u003e array('pipe', 'r'),\n\t\t\t1 =\u003e array('pipe', 'w'),\n\t\t\t2 =\u003e array('pipe', 'w')\n\t\t);\n\n\t\t//Open process\n\t\tif (is_resource($proc = proc_open($this-\u003ebin, $descriptorSpec, $pipes))) {\n\t\t\t//Set stderr as non blocking\n\t\t\tstream_set_blocking($pipes[2], false);\n\n\t\t\t//Send content to stdin\n\t\t\tfwrite($pipes[0], $content);\n\n\t\t\t//Close stdin\n\t\t\tfclose($pipes[0]);\n\n\t\t\t//Read content from stdout\n\t\t\tif ($stdout = stream_get_contents($pipes[1])) {\n\t\t\t\t$content = $stdout;\n\t\t\t}\n\n\t\t\t//Close stdout\n\t\t\tfclose($pipes[1]);\n\n\t\t\t//Read content from stderr\n\t\t\tif (($stderr = stream_get_contents($pipes[2]))) {\n\t\t\t\tthrow new Error(sprintf('Got unexpected strerr for %s: %s', $this-\u003ebin, $stderr), $this-\u003eline, $this-\u003efileName);\n\t\t\t}\n\n\t\t\t//Close stderr\n\t\t\tfclose($pipes[2]);\n\n\t\t\t//Close process\n\t\t\tif (($ret = proc_close($proc))) {\n\t\t\t\tthrow new Error(sprintf('Got unexpected non zero return code %s: %d', $this-\u003ebin, $ret), $this-\u003eline, $this-\u003efileName);\n\t\t\t}\n\t\t}\n\n\t\t//Return content\n\t\treturn $content;\n\t}\n}\n```\n\nThe class must implements FilterInterface and get it's arguments through constructor.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapsys%2Fpackbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frapsys%2Fpackbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapsys%2Fpackbundle/lists"}