{"id":13828090,"url":"https://github.com/nikic/include-interceptor","last_synced_at":"2025-05-09T01:46:45.046Z","repository":{"id":36841770,"uuid":"230679735","full_name":"nikic/include-interceptor","owner":"nikic","description":"Library to intercept and dynamically transform PHP includes. Forked from icewind1991/interceptor.","archived":false,"fork":false,"pushed_at":"2024-07-13T09:06:20.000Z","size":66,"stargazers_count":69,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-09T01:46:38.817Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2019-12-28T23:29:17.000Z","updated_at":"2024-07-13T09:06:23.000Z","dependencies_parsed_at":"2024-03-24T08:34:05.500Z","dependency_job_id":"995758ec-bfad-4f8d-b034-4edcdba4d040","html_url":"https://github.com/nikic/include-interceptor","commit_stats":{"total_commits":46,"total_committers":4,"mean_commits":11.5,"dds":0.5217391304347826,"last_synced_commit":"1e2f2adf8712df6a64a039c046825929c9abb1f3"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikic%2Finclude-interceptor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikic%2Finclude-interceptor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikic%2Finclude-interceptor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikic%2Finclude-interceptor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikic","download_url":"https://codeload.github.com/nikic/include-interceptor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253176443,"owners_count":21866142,"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":[],"created_at":"2024-08-04T09:02:31.878Z","updated_at":"2025-05-09T01:46:45.021Z","avatar_url":"https://github.com/nikic.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Include Interceptor\n\nLibrary to intercept PHP includes. A fork of [icewind1991/interceptor](https://github.com/icewind1991/interceptor).\n\n```\ncomposer require nikic/include-interceptor\n```\n\n## Usage\n\n```php\nuse Nikic\\IncludeInterceptor\\Interceptor;\n\n$interceptor = new Interceptor(function(string $path) {\n    if (!wantToIntercept($path)) {\n        return null;\n    }\n    return transformCode(file_get_contents($path));\n});\n$interceptor-\u003esetUp(); // Start intercepting includes\n\nrequire 'src/foo.php';\n\n$interceptor-\u003etearDown(); // Stop intercepting includes\n```\n\nThe interception hook follows the following contract:\n\n * It is only called if the included file exists.\n * The passed `$path` is the realpath.\n * If the hook returns `null`, no interception is performed.\n * If the hook returns a string, these are taken as the transformed content of the file.\n\nFor convenience, a `FileFilter` is provided that implements white- and black-listing\nof files and directories. Paths passed to `addBlackList()` and `addWhiteList()` should\nalways be realpaths.\n\n```php\nuse Nikic\\IncludeInterceptor\\Interceptor;\nuse Nikic\\IncludeInterceptor\\FileFilter;\n\n$fileFilter = FileFilter::createAllWhitelisted();    // Start with everything whitelisted\n$fileFilter-\u003eaddBlackList(__DIR__ . '/src/');        // Blacklist the src/ directory\n$fileFilter-\u003eaddWhiteList(__DIR__ . '/src/foo.php'); // But whitelist the src/foo.php file\n$interceptor = new Interceptor(function(string $path) use ($fileFilter) {\n    if (!$fileFilter-\u003etest($path)) {\n        return null;\n    }\n    return transformCode(file_get_contents($path));\n});\n$interceptor-\u003esetUp();\n\nrequire 'src/foo.php';\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikic%2Finclude-interceptor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikic%2Finclude-interceptor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikic%2Finclude-interceptor/lists"}