{"id":17762056,"url":"https://github.com/kocsismate/php-di-container-benchmarks","last_synced_at":"2025-03-15T11:33:02.093Z","repository":{"id":57007909,"uuid":"77353926","full_name":"kocsismate/php-di-container-benchmarks","owner":"kocsismate","description":"Benchmark for some popular PHP Dependency Injection Containers.","archived":false,"fork":false,"pushed_at":"2023-07-31T17:36:03.000Z","size":2353,"stargazers_count":77,"open_issues_count":4,"forks_count":27,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-02-27T01:47:41.473Z","etag":null,"topics":["benchmark","dependency-injection","di-containers","php"],"latest_commit_sha":null,"homepage":"https://kocsismate.github.io/php-di-container-benchmarks/benchmark.html","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/kocsismate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-26T02:59:26.000Z","updated_at":"2024-12-28T22:36:49.000Z","dependencies_parsed_at":"2022-08-21T14:31:28.743Z","dependency_job_id":null,"html_url":"https://github.com/kocsismate/php-di-container-benchmarks","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/kocsismate%2Fphp-di-container-benchmarks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kocsismate%2Fphp-di-container-benchmarks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kocsismate%2Fphp-di-container-benchmarks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kocsismate%2Fphp-di-container-benchmarks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kocsismate","download_url":"https://codeload.github.com/kocsismate/php-di-container-benchmarks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243725011,"owners_count":20337660,"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":["benchmark","dependency-injection","di-containers","php"],"created_at":"2024-10-26T19:51:07.618Z","updated_at":"2025-03-15T11:33:00.378Z","avatar_url":"https://github.com/kocsismate.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP DI Container Benchmarks\n\n[![Software License][ico-license]](LICENSE)\n[![Gitter][ico-gitter]][link-gitter]\n\n## Table of Contents\n\n* [Introduction](#introduction)\n* [Results](#results)\n* [Install](#install)\n* [Usage](#usage)\n* [Contributing](#contributing)\n* [Support](#support)\n* [Credits](#credits)\n* [License](#license)\n\n## Introduction\n\nIn 2014, a really interesting benchmark about DI Containers for PHP\n[was published](https://www.sitepoint.com/php-dependency-injection-container-performance-benchmarks/) on Sitepoint.\nUnfortunately, [the implementation](https://github.com/TomBZombie/php-dependency-injection-benchmarks) of the tests\nturned out to be quite controversial, so the benchmark itself wasn't really insightful.\n\nI have been interested in the topic since then so I wanted to conduct another benchmark that also tries to measure real-life\nperformance, while being as unbiased and reliable as possible.\n\n## Results\n\nYou can find the benchmark results [here](https://kocsismate.github.io/php-di-container-benchmarks/benchmark.html).\n\n## Install\n\nYou can simply download or clone this repository as well as install it via [Composer](https://getcomposer.org) by\nrunning the command below:\n\n```bash\n$ composer require kocsismate/di-container-benchmarks:dev-master\n```\n\n## Usage\n\n### Usage with Docker\n\nAs a prerequisite, [Docker Compose](https://www.docker.com/products/docker-compose) and at least Docker\n17.06 CE has to be installed on your machine in order to use this benchmark method.\n\nCopy the `.env.dist` file to `.env` and feel free to override the values in it. Now, you can run\n\n```bash\n./benchmark.sh docker\n```\n\nto execute the measurements.\n\nThe HTML output will be generated in the \"docs\" directory.\n\n### Usage on AWS EC2\n\nAs a prerequisite, [Terraform](https://www.terraform.io) and `git` has to be installed on your machine\nin order to use this benchmark method.\n\nFirst, create the necessary config file by copying the `aws.tfvars.dist` to `aws.tfvars` in the\n`build/infrastructure/config/aws.tfvars.dist` directory:\n\n```bash\ncp build/infrastructure/config/aws.tfvars.dist build/infrastructure/config/aws.tfvars\n```\n\nThen, override the values in it:\n\n- `access_key`: the access key of your AWS account\n- `secret_key`: the secret access key of your AWS account\n- `ssh_key_name`: the name of your key pair added to EC2\n- `ssh_private_key`: the file name of your private key\n- `region`: it is \"eu-central-1\" by default, but you should choose the closest one to your area\n- `image_name`: the name of the EC2 image\n- `image_architecture`: the CPU architecture of the EC2 image (e.g. x86_64 or arm64)\n- `instance_type`: it is \"C5.large\" by default (this instance type is out of the scope of the free tier!)\n\nFinally, you have to copy your private key in the \"build/infrastructure/config\" directory with a file name that matches\nthe one defined in the `ssh_private_key` setting.\n\nNow, you are ready to go:\n\n```bash\n./benchmark.sh aws\n```\n\nThe HTML output will be generated in the \"docs\" directory.\n\n### Usage on your host machine\n\nIf the above possibilities aren't available to you then you have to take several steps before running the benchmark:\n\n- Install a web server and configure it to be able to serve \"public/index.php\"\n- Install PHP 8.0 at least with OPcache and preloading enabled\n- Install Composer\n- Set the `BENCHMARK_URL` environment variable to the URL where \"public/index.php\" is available. For instance:\n\n```bash\nexport BENCHMARK_URL=http://localhost/index.php\n```\n\nNow you can simply type the following in order to run the benchmark:\n\n```bash\n.\\benchmark.sh host\n```\n\nIf you don't want to specify the benchmark URL as an environment variable then you can also pass it as an argument:\n\n```bash\n./benchmark.sh host http://localhost/index.php\n```\n\n### Usage from the browser\n\nYou can even run tests manually from your browser. When the benchmark's Docker containers are running, just visit\n`localhost:8090`, otherwise you have to locate the `BENCHMARK_URL` URL (mentioned in the previous section). For further\ninformation, refer to the URL in question, it provides you with detailed instructions.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Support\n\nPlease see [SUPPORT](SUPPORT.md) for details.\n\n## Credits\n\n- [Máté Kocsis][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see the [License File](LICENSE) for more information.\n\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg\n[ico-gitter]: https://badges.gitter.im/kocsismate/php-di-container-benchmarks.svg\n\n[link-gitter]: https://gitter.im/kocsismate/php-di-container-benchmarks?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\n[link-author]: https://github.com/kocsismate\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkocsismate%2Fphp-di-container-benchmarks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkocsismate%2Fphp-di-container-benchmarks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkocsismate%2Fphp-di-container-benchmarks/lists"}