{"id":15690335,"url":"https://github.com/halkyon/incapsula-php","last_synced_at":"2025-05-07T23:37:11.278Z","repository":{"id":139897157,"uuid":"137643608","full_name":"halkyon/incapsula-php","owner":"halkyon","description":"This project contains a PHP SDK to use the Incapsula API programmatically, as well as providing command line tools for executing various tasks against the Incapsula API.","archived":false,"fork":false,"pushed_at":"2020-03-16T08:57:29.000Z","size":58,"stargazers_count":2,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T23:42:12.031Z","etag":null,"topics":["api","cli","imperva","incapsula","php","sdk"],"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/halkyon.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":"2018-06-17T09:36:43.000Z","updated_at":"2024-07-11T09:56:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"918e665a-3a54-4a6d-b541-e97713343ccd","html_url":"https://github.com/halkyon/incapsula-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halkyon%2Fincapsula-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halkyon%2Fincapsula-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halkyon%2Fincapsula-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halkyon%2Fincapsula-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halkyon","download_url":"https://codeload.github.com/halkyon/incapsula-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243042922,"owners_count":20226722,"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":["api","cli","imperva","incapsula","php","sdk"],"created_at":"2024-10-03T18:08:44.849Z","updated_at":"2025-03-11T13:32:02.727Z","avatar_url":"https://github.com/halkyon.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://img.shields.io/circleci/project/github/halkyon/incapsula-php/master.svg?style=flat-square)](https://circleci.com/gh/halkyon/incapsula-php)\n[![Code Quality](https://img.shields.io/scrutinizer/g/halkyon/incapsula-php/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/halkyon/incapsula-php)\n\n# Incapsula PHP SDK\n\n## Introduction\n\nThis project contains a PHP SDK to use the Incapsula API programmatically, as well as providing\ncommand line tools for executing various tasks against the Incapsula API.\n\nPlease see the [public API docs for Incapsula/Imperva](https://docs.imperva.com/bundle/cloud-application-security/page/api/api.htm)\nfor more information on how the API works.\n\n## Installation\n\n1. Clone the repo locally: `git clone git@github.com:halkyon/incapsula-php.git`.\n2. Run `composer install` to install dependencies.\n3. Configure your Incapsula API credentials (see below).\n4. Test your credentials using the `./bin/incapsula sites:list` command\n5. See a list of all commands you can run by calling `./bin/incapsula`\n\n## Configuring credentials\n\nYou can define credentials either as environment variables `INCAPSULA_API_ID` and `INCAPSULA_API_KEY`,\nor as a credential file located in the current user home directory `~/.incapsula/credentials`.\n\nOrder of preference is environment variables first, then ini file.\n\nNote: Environment variables must be actually set as env vars, not just added in a `.env` file in the application root.\n\nIf you're confident about the security of your machine, you can define them on the command-line, for example:\n`INCAPSULA_API_ID=ABC123 INCAPSULA_API_KEY=xyz789 ./bin/incapsula sites:list` \n\nExample ini file:\n```\n[default]\nincapsula_api_id = 123\nincapsula_api_key = 1234-5678\n```\n\nAdditional profiles can be added by defining more `[section]`s in the file. These are then used\nby passing the `--profile \u003cname\u003e` option to commands.\n\n## Usage\n\nRun `./bin/incapsula` to show a listing of all available commands.\n\nSome commands have a `--json` argument which returns as JSON instead of output as a table.\n\n## Example command usage\n\n### List IP ranges\n\n```\nincapsula integration:ips\n```\n\n### List sites\n\n```\nincapsula sites:list\n```\n\n### List all cache rules for all sites\n\n```\nincapsula sites:listcacherules\n```\n### Upload custom certificate\n\n```\nincapsula customcertificate:upload \u003csite-id\u003e \u003ccertificate-path\u003e \u003cprivate-key-path\u003e\n```\n\n## Example SDK usage\n\nUse the sites API to enumerate all available sites, create a new site, upload a custom certitificate,\nthen remove what was created:\n\n```php\n$client = new Incapsula\\Client();\n$sitesApi = $client-\u003esites();\n\n$sites = $sitesApi-\u003elist();\nforeach ($sites as $site) {\n    var_dump($site['site_id']);\n}\n\n$site = $sitesApi-\u003eadd([\n    'domain' =\u003e 'mysite.com',\n]);\n\nvar_dump($site['site_id']);\n\n$sitesApi-\u003euploadCustomCertificate($site['site_id'], '---- CERT ----', '---- KEY ----');\n$sitesApi-\u003eremoveCustomCertificate($site['site_id']);\n\n$sitesApi-\u003edelete($site['site_id']);\n```\n\nUse the integration API to retrieve Incapsula IP ranges:\n\n```php\n$client = new Incapsula\\Client();\n$ips = $client-\u003eintegration()-\u003eips();\nvar_dump($ips['ipRanges']);\nvar_dump($ips['ipv6Ranges']);\n```\n\n## Contributing\n\nBefore making a pull request, please run the code syntax fixer to make sure the linter works: `vendor/bin/php-cs-fixer fix`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalkyon%2Fincapsula-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalkyon%2Fincapsula-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalkyon%2Fincapsula-php/lists"}