net_bazzline / php_component_memory_limit_manager
free as in freedom php component to validate if your script is reaching the allowed maximum memory usage
Installs: 766
Dependents: 1
Suggesters: 0
Security: 0
Stars: 8
Watchers: 7
Forks: 1
Open Issues: 0
Language:JavaScript
Requires
- php: >=5.3.3
Requires (Dev)
- mockery/mockery: 0.9.4
- phpunit/phpunit: ~4.8||~5.2
README
I still like the idea but there is currently no use case to develop it anymore.
Memory Limit Manager Component for PHP
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:
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
- @todo
- 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
- added missing DependentInterface and AwareInterface
- 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 :-))