net_bazzline/php_component_memory_limit_manager

Supports you to validate if your script is reaching the allowed maximum memory usage

1.1.0 2016-02-27 11:29 UTC

README

This free as in freedom component helps you to validate if your script reaches the allowed maximum memory limit.

Furthermore, you can set your own memory limit (as long as it is below the limit in you php.ini).

The build status of the current master branch is tracked by Travis CI: build status Latest stable

The scrutinizer status are: code quality

The versioneye status is: dependencies

Downloads: Downloads this Month

It is also available at openhub.net.

Benefits

  • provides easy setting of memory limit
  • gives you the advantage to add a buffer before reaching the limit to easy up reacting when limit is reached
  • helps you to set the limit in bytes, kilo bytes, mega bytes or giga bytes (same for the buffer)
  • comes with DependentInterface and AwareInterface

Examples

Install

By Hand

mkdir -p vendor/net_bazzline/php_component_memory_limit_manager
cd vendor/net_bazzline/php_component_memory_limit_manager
git clone https://github.com/bazzline/php_component_memory_limit_manager

With Packagist

composer require net_bazzline/php_component_memory_limit_manager:dev-master

Usage

$manager = new Net\Bazzline\Component\MemoryLimitManager\MemoryLimitManager();
$manager->setBufferInMegaBytes(4);
$manager->setLimitInMegaBytes(64);

while (!empty($dataSet)) {
    if ($manager->isLimitReached()) {
        //exit while loop, shutdown process
    } else {
        $data = array_shift($dataSet);
        //work on data set
    }
}

API

Thanks to apigen, the api is available in the document section or online.

History

  • upcomming
    • @todo
      • implement way of measure/calculate the amount of memory for next iteration
  • 1.1.0 - released at 27.02.2016
    • added dedicated travis integration test for php 7.0
    • moved to psr-4 autoloading
    • removed code coverage
    • removed dead link
    • removed dependency to phpmd
    • updated dependencies
  • 1.0.9 - released at 11.12.2015
    • updated dependencies
  • 1.0.8 - released at 18.11.2015
    • updated dependencies
  • 1.0.7 - released at 27.08.2015
    • updated dependencies
  • 1.0.6 - released at 04.07.2015
    • updated dependencies
  • 1.0.5 - released at 22.05.2015
    • updated dependencies
  • 1.0.4 - released at 02.08.2015
    • updated dependencies
    • removed dependency to apigen
  • 1.0.3 - released at 31.08.2014
    • fixed broken composer.json
  • 1.0.2 - released at 31.08.2014
    • added versioneye
    • added scrutinizer
    • fixed small bugs
    • updated dependencies
  • 1.0.1 - released at 27.07.2014
  • 1.0.0 - released at 27.07.2014
    • initial commit with examples, unit tests and api documentation

Future Improvements

  • if you have one, create a feature request, fork it (and push it back :-))