{"id":18929496,"url":"https://github.com/thecodingmachine/common-factories","last_synced_at":"2025-10-07T09:15:42.265Z","repository":{"id":57067847,"uuid":"57879476","full_name":"thecodingmachine/common-factories","owner":"thecodingmachine","description":"This project provides utility factories that can be used directly in service providers complying with the container-interop/service-provider standard.","archived":false,"fork":false,"pushed_at":"2018-08-17T21:28:36.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-24T10:59:27.651Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/thecodingmachine.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}},"created_at":"2016-05-02T09:47:45.000Z","updated_at":"2019-04-03T08:25:26.000Z","dependencies_parsed_at":"2022-08-24T14:54:08.159Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/common-factories","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/thecodingmachine/common-factories","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fcommon-factories","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fcommon-factories/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fcommon-factories/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fcommon-factories/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/common-factories/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fcommon-factories/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278747959,"owners_count":26038821,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-08T11:33:00.804Z","updated_at":"2025-10-07T09:15:42.249Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/thecodingmachine/common-factories/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/thecodingmachine/common-factories/?branch=master)\n[![Build Status](https://travis-ci.org/thecodingmachine/common-factories.svg?branch=master)](https://travis-ci.org/thecodingmachine/common-factories)\n[![Coverage Status](https://coveralls.io/repos/thecodingmachine/common-factories/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/thecodingmachine/common-factories?branch=master)\n\n\n# Utility factories for container-interop/service-provider\n\n**Work in progress.**\n\nThis project is part of the [container-interop](https://github.com/container-interop/container-interop) group. It tries to find a solution for cross-framework modules (aka bundles) by the means of container-agnostic configuration.\n\n## Goal of this project\n\nThis project provides utility factories that can be used directly in service providers complying with the [container-interop/service-provider](https://github.com/container-interop/service-provider) standard.\n\nThose common factories can be detected by compiled/cached containers. The aim of this package is to offer a common set of useful classes that can also be preprocessed by optimized containers for best performance.\n\n## Usage\n\nSimply require this package in your package declaring your service-provider:\n\n**So far, the package has the thecodingmachine vendor name. It will hopefully be migrated to  container-interop/common-factories**\n\n```sh\ncomposer require thecodingmachine/common-factories\n```\n\nThen, you can use one of the 3 available classes:\n\n### Creating an alias\n\nUse the `Alias` class to easily create an alias.\n\n```php\npublic function getFactories() {\n    return [\n        'myAlias' =\u003e new Alias('myService')\n    ]\n}\n```\n\ncan easily replace:\n\n```php\npublic function getFactories() {\n    return [\n        'myAlias' =\u003e function(ContainerInterface $container) {\n            return $container-\u003eget('myService');\n        }\n    ]\n}\n```\n\n### Creating a parameter\n\nUse the `Parameter` class to put in the container a scalar (or array of scalar) entry:\n\n```php\npublic function getFactories() {\n    return [\n        'DB_HOST' =\u003e new Parameter('localhost')\n    ]\n}\n```\n\ncan easily replace:\n\n```php\npublic function getFactories() {\n    return [\n        'DB_HOST' =\u003e function() {\n            return 'localhost';\n        }\n    ]\n}\n```\n\n### Appending a service to an array of services\n\nUse the `AddToArray` class to push a new service to an existing array:\n\n```php\npublic function getExtensions() {\n    return [\n        MyTwigExtension::class =\u003e function() {\n            return new MyTwigExtension();\n        },\n        'twig.extensions' =\u003e new AddToArray(MyTwigExtension::class)\n    ]\n}\n```\n\ncan easily replace:\n\n```php\npublic function getExtensions() {\n    return [\n        MyTwigExtension::class =\u003e function() {\n            return new MyTwigExtension();\n        },\n        'twig.extensions' =\u003e function(ContainerInterface $container, array $extensions = []) {\n            $extensions[] = $container-\u003eget(MyTwigExtension::class);\n            return $extensions;\n        }\n    ]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fcommon-factories","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Fcommon-factories","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fcommon-factories/lists"}