{"id":21064410,"url":"https://github.com/brandembassy/php-memory","last_synced_at":"2025-05-16T02:32:38.408Z","repository":{"id":53311605,"uuid":"130479711","full_name":"BrandEmbassy/php-memory","owner":"BrandEmbassy","description":"A simple tool to provide an easy-to-use API to convert memory limit configuration from php.ini to bytes.","archived":false,"fork":false,"pushed_at":"2025-02-20T03:44:49.000Z","size":34,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-20T17:19:54.947Z","etag":null,"topics":["memory","memory-allocation","php","php7"],"latest_commit_sha":null,"homepage":null,"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/BrandEmbassy.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-04-21T14:09:02.000Z","updated_at":"2023-10-11T11:22:19.000Z","dependencies_parsed_at":"2024-11-19T18:01:44.686Z","dependency_job_id":null,"html_url":"https://github.com/BrandEmbassy/php-memory","commit_stats":{"total_commits":10,"total_committers":2,"mean_commits":5.0,"dds":0.09999999999999998,"last_synced_commit":"beb449b1c53806bbcda7103b5deded987cc936bd"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrandEmbassy%2Fphp-memory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrandEmbassy%2Fphp-memory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrandEmbassy%2Fphp-memory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrandEmbassy%2Fphp-memory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BrandEmbassy","download_url":"https://codeload.github.com/BrandEmbassy/php-memory/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254456136,"owners_count":22074111,"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":["memory","memory-allocation","php","php7"],"created_at":"2024-11-19T17:49:27.850Z","updated_at":"2025-05-16T02:32:35.261Z","avatar_url":"https://github.com/BrandEmbassy.png","language":"PHP","readme":"# PHP Memory Limit\n\nA simple tool to provide an easy-to-use API to convert memory limit configuration from `php.ini` to bytes.\n\n## Why\nCore directive `memory_limit` in `php.ini` is a simple string. An administrator or a programmer can set several valid values, e.g.:\n- `500` = 500 bytes\n- `128M` = 134 217 728 bytes\n- `1G` = 1 073 741 824 bytes\n\nYou can obtain the original string value through `ini_get('memory_limit')` function. However, there is no built-in PHP function to provide an easy access to the byte value.\n\n## Installation\nAdd the package to your `composer.json`:\n\n```\ncomposer require brandembassy/php-memory\n```\n\n## Usage\nCreate the `MemoryLimitProvider `service (or better, inject it using your DI container):\n```\n$configuration = new \\BrandEmbassy\\Memory\\MemoryConfiguration();\n$limitProvider = new \\BrandEmbassy\\Memory\\MemoryLimitProvider($configuration);\n```\n\nThere is also a DI extension for Nette Framework (you must have the `nette/di` package installed). Just register it in your `services.neon` file:\n```\nextensions:\n    - BrandEmbassy\\Memory\\Bridge\\MemoryLimitNetteExtension\n```\n\nYou can then access the byte value of PHP memory limit like this:\n```\n$limitInBytes = $memoryLimitProvider-\u003egetLimitInBytes();\n```\n\n*Any questions or ideas to improve? Feel free to open an issue or send a PR!*\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandembassy%2Fphp-memory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrandembassy%2Fphp-memory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandembassy%2Fphp-memory/lists"}