{"id":13804043,"url":"https://github.com/jakoch/phantomjs-installer","last_synced_at":"2025-05-15T03:05:57.965Z","repository":{"id":47306063,"uuid":"11861935","full_name":"jakoch/phantomjs-installer","owner":"jakoch","description":"A Composer Package which installs the PhantomJS binary (Linux, Windows, Mac) into /bin of your project.","archived":false,"fork":false,"pushed_at":"2025-02-25T01:07:09.000Z","size":155,"stargazers_count":152,"open_issues_count":1,"forks_count":43,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-30T16:12:11.599Z","etag":null,"topics":["composer","phantomjs","phantomjs-installation","php"],"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/jakoch.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jakoch"}},"created_at":"2013-08-03T10:59:36.000Z","updated_at":"2025-04-10T09:29:28.000Z","dependencies_parsed_at":"2025-02-28T17:11:27.819Z","dependency_job_id":"5d035cfa-3ea7-450f-a64e-abdbfc2455d2","html_url":"https://github.com/jakoch/phantomjs-installer","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakoch%2Fphantomjs-installer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakoch%2Fphantomjs-installer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakoch%2Fphantomjs-installer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakoch%2Fphantomjs-installer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakoch","download_url":"https://codeload.github.com/jakoch/phantomjs-installer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252405970,"owners_count":21742690,"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":["composer","phantomjs","phantomjs-installation","php"],"created_at":"2024-08-04T01:00:40.718Z","updated_at":"2025-05-15T03:05:57.946Z","avatar_url":"https://github.com/jakoch.png","language":"PHP","funding_links":["https://github.com/sponsors/jakoch"],"categories":["Scripts"],"sub_categories":["Support"],"readme":"phantomjs-installer\n===================\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/jakoch/phantomjs-installer)](https://packagist.org/packages/jakoch/phantomjs-installer)\n[![Total Downloads](https://img.shields.io/packagist/dt/jakoch/phantomjs-installer)](https://packagist.org/packages/jakoch/phantomjs-installer)\n[![Build Status](https://github.com/jakoch/phantomjs-installer/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/jakoch/phantomjs-installer/actions/workflows/ci.yml)\n[![License](https://img.shields.io/packagist/l/jakoch/phantomjs-installer)](https://packagist.org/packages/jakoch/phantomjs-installer)\n\nA Composer package which installs the PhantomJS binary (Linux, Windows, Mac) into `/bin` of your project.\n\n##### Table of Contents\n\n- [phantomjs-installer](#phantomjs-installer)\n        - [Table of Contents](#table-of-contents)\n  - [Installation](#installation)\n  - [How to require specific versions of PhantomJS?](#how-to-require-specific-versions-of-phantomjs)\n  - [How does this work internally?](#how-does-this-work-internally)\n  - [PhantomBinary](#phantombinary)\n  - [Override platform requirements](#override-platform-requirements)\n  - [Downloading from a mirror](#downloading-from-a-mirror)\n  - [Automatic download retrying with version lowering on 404](#automatic-download-retrying-with-version-lowering-on-404)\n\n## Installation\n\nTo install PhantomJS as a local, per-project dependency to your project, simply add a dependency on `jakoch/phantomjs-installer` to your project's `composer.json` file.\n\n\n```json\n{\n    \"require\": {\n        \"jakoch/phantomjs-installer\": \"^3\"\n    },\n    \"config\": {\n        \"bin-dir\": \"bin\"\n    },\n    \"scripts\": {\n        \"post-install-cmd\": [\n            \"PhantomInstaller\\\\Installer::installPhantomJS\"\n        ],\n        \"post-update-cmd\": [\n            \"PhantomInstaller\\\\Installer::installPhantomJS\"\n        ]\n    }\n}\n```\n\nFor a development dependency, change `require` to `require-dev`.\n\nThe default download source used is: https://bitbucket.org/ariya/phantomjs/downloads/\nYou might change it by setting a custom CDN URL, which is explained in the section \"[Downloading from a mirror](#downloading-from-a-mirror)\".\n\nBy setting the Composer configuration directive `bin-dir`, the [vendor binaries](https://getcomposer.org/doc/articles/vendor-binaries.md#can-vendor-binaries-be-installed-somewhere-other-than-vendor-bin-) will be installed into the defined folder.\n**Important! Composer will install the binaries into `vendor\\bin` by default.**\n\nThe `scripts` section is necessary, because currently Composer does not pass events to the handler scripts of dependencies. If you leave it away, you might execute the installer manually.\n\nNow, assuming that the scripts section is set up as required, the PhantomJS binary\nwill be installed into the `/bin` folder and updated alongside the project's Composer dependencies.\n\n## How to require specific versions of PhantomJS?\n\nThe environment and server variable `PHANTOMJS_VERSION` enables you specify the version requirement at the time of packaging.\n\nYou can also set the `phantomjs-version` in the `extra` section of your `composer.json`:\n\n ```json\n  \"extra\": {\n    \"jakoch/phantomjs-installer\": {\n      \"phantomjs-version\": \"2.1.1\"\n    }\n  }\n ```\n\nThe search order for the version is 1) $_ENV, 2) $_SERVER, 3) `composer.json` (extra section), 4) fallback to v2.1.1 (hardcoded latest version).\n\n\n## How does this work internally?\n\n1. **Fetching the PhantomJS Installer**\n\n In your composer.json you require the package \"phantomjs-installer\".\n The package is fetched by composer and stored into `./vendor/jakoch/phantomjs-installer`.\n It contains only one file the `PhantomInstaller\\\\Installer`.\n\n2. **Platform-specific download of PhantomJS**\n\n The `PhantomInstaller\\\\Installer` is run as a \"post-install-cmd\". That's why you need the \"scripts\" section in your \"composer.json\".\n The installer creates a new composer in-memory package \"phantomjs\",\n detects your OS and downloads the correct Phantom version to the folder `./vendor/jakoch/phantomjs`.\n All PhantomJS files reside there, especially the `examples`.\n\n3. **Installation into `/bin` folder**\n\n The binary is then copied from `./vendor/jakoch/phantomjs` to your composer configured `bin-dir` folder.\n\n4. **Generation of PhantomBinary**\n\n The installer generates a PHP file `PhantomInstaller\\\\PhantomBinary` and inserts the path to the binary.\n\n## PhantomBinary\n\nTo access the binary and its folder easily, the class `PhantomBinary` is created automatically during installation.\n\nThe class defines the constants `BIN` and `DIR`:\n  - `BIN` is the full-path to the PhantomJS binary file, e.g. `/your_project/bin/phantomjs`\n  - `DIR` is the folder of the binary, e.g. `/your_project/bin`\n\nBoth constants are also accessible via their getter-methods `getBin()` and `getDir()`.\n\nUsage:\n\n    use PhantomInstaller\\PhantomBinary;\n\n    // get values with class constants\n\n    $bin = PhantomInstaller\\PhantomBinary::BIN;\n    $dir = PhantomInstaller\\PhantomBinary::DIR;\n\n    // get values with static functions\n\n    $bin = PhantomInstaller\\PhantomBinary::getBin();\n    $dir = PhantomInstaller\\PhantomBinary::getDir();\n\nThis feature is similar to `location.js` of the [phantomjs module](https://github.com/Medium/phantomjs/blob/master/install.js#L93) for Node.\n\n## Override platform requirements\n\nThe environment and server variables `PHANTOMJS_PLATFORM` and `PHANTOMJS_BITSIZE` enable you to\noverride the platform requirements at the time of packaging. This decouples the packaging system\nfrom the target system. It allows to package on Linux for MacOSX or on Windows for Linux.\n\nPossible values for\n - `PHANTOMJS_PLATFORM` are: `macosx`, `windows`, `linux`.\n - `PHANTOMJS_BITSIZE` are: `32`or `64`.\n\n## Downloading from a mirror\n\nYou can override the default download location of the PhantomJS binary file by setting it in one of these locations. Listed in order of precedence (highest first):\n* The environment variable `PHANTOMJS_CDNURL`\n* The server variable `PHANTOMJS_CDNURL`\n* In your `composer.json` by using `$['extra']['jakoch/phantomjs-installer']['cdnurl']`:\n\n ```json\n  \"extra\": {\n    \"jakoch/phantomjs-installer\": {\n      \"cdnurl\": \"https://github.com/Medium/phantomjs/releases/download/v1.9.19/\"\n    }\n  },\n ```\n\n**Default Download Location**\n\nThe default download location is Bitbucket: `https://api.bitbucket.org/2.0/repositories/ariya/phantomjs/downloads/`.\nYou don't need to set it explicitly. It's used, when `PHANTOMJS_CDNURL` is not set.\n\n**Mirrors**\n\nYou might use one of the following mirror URLs as a value for `PHANTOMJS_CDNURL`:\n  - `https://cnpmjs.org/downloads/` - USA, San Mateo (47.88.189.193)\n  - `https://npm.taobao.org/mirrors/phantomjs/` - China, Hangzhou (114.55.80.225)\n  - `https://github.com/Medium/phantomjs/` - USA, San Francisco (192.30.253.113)\n\nThis list of mirrors is not complete. If you know another mirror, please don't hesitate to add it here.\n\nThe mirror URLs are also not hardcoded, except for the Github URL.\nThis enables you to point to any PhantomJS mirror or download folder you like.\nFor instance, you could point to the URL of the download folder of your company, where the binaries are stored:\n`PHANTOMJS_CDNURL=https://cdn.company.com/downloads/phantomjs/`.\n\n## Automatic download retrying with version lowering on 404\n\nIn case downloading an archive fails with HttpStatusCode 404 (resource not found),\nthe downloader will automatically lower the version to the next available version\nand retry. The number of retries is determined by the number of hardcoded PhantomJS\nversions in `getPhantomJSVersions()`. This feature was added, because of the problems\nwith v2.0.0 not being available for all platforms (see issue #25).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakoch%2Fphantomjs-installer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakoch%2Fphantomjs-installer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakoch%2Fphantomjs-installer/lists"}