2015. április 30., csütörtök

Preventing Memory Leaks in PHP

Image resizing need memory. I use this script to prevent memory leak.


I use Intervention Image library for resizing I often get ‘Allowed memory size of …. bytes exhausted (tried to allocate … bytes)’ message.


////////////////////////////////////////////////////

//get memory_limit info from php.ini

$memoryAvailable = filter_var(ini_get(“memory_limit”), FILTER_SANITIZE_NUMBER_INT) * 1048576;


//getting the image width and height

$imageInfo = getimagesize($destinationPath . ‘/’ . $filename);


//This is quite rough and includes a fudge factor, 2.5, which you may want to experiment with.

$requiredMemory = ( $imageInfo[0] * $imageInfo[1] * ($imageInfo[‘bits’] / 8) * $imageInfo[‘channels’] * 2.5 );


//check memory usage

if (memory_get_usage() + $requiredMemory < $memoryAvailable)


//we have enough memory to resize the image.


////////////////////////////////////////////////////



Preventing Memory Leaks in PHP

2015. április 29., szerda

Laravel log viewer

Inspired by Micheal Mand’s Laravel 4 log viewer.


Log Viewer for Laravel 5 (compatible with 4.2 too).


Install:


composer require rap2hpoutre/laravel-log-viewer


Add Service Provider to config/app.php in providers section


‘Rap2hpoutre\LaravelLogViewer\LaravelLogViewerServiceProvider’,


Add a route in app/Http/routes.php (or choose another route):


Route::get(‘logs’, ‘\Rap2hpoutre\LaravelLogViewer\LogViewerController@index’);


my advice:

//protect log viewer with superamin filter


Route::get(logs”, [

‘before’ => ‘superadmin’,

“uses” => ‘\Rap2hpoutre\LaravelLogViewer\LogViewerController@index’

]);


https://github.com/rap2hpoutre/laravel-log-viewer



Laravel log viewer

2015. április 25., szombat

Run your own auction site on your PHP - MySQL hosting service

Laravel auction software (PHP – MySQL ) on binpress.com: http://www.binpress.com/app/php-laravel-auction/2822


Laravel auction


Everybody loves eBay. However, not everyone likes the commissions you have to pay to sell on the site.


What if you love the idea of eBay but want to run an auction from site of your own? This could be to sell general items or it could be to sell very specific items at auction.


There are many reasons to create a website based around auction software. You don’t have to completely go down the general eBay item route, but instead have a site that runs a very specific auction.


An example that springs to mind instantly would be to create a website that allows you to run a charity auction for a selection of items on one evening. This would work in the same way as eBay but run over the space of a single evening.


Other reasons to setup your own auction website would be to avoid paying commissions on each auction item as well as having the ability to style the website in any manner you wish.



Run your own auction site on your PHP - MySQL hosting service

Run your own auction site on

Laravel auction software on binpress.com: http://www.binpress.com/app/php-laravel-auction/2822



Run your own auction site on

2015. április 24., péntek

Uninstall Laravel package

  1. Remove declaration from composer.json (in “require” section)

  2. Remove Service Provider from “app/config/app.php” (reference in “providers” array)

  3. Remove any Class Aliases from “app/config/app.php”

  4. Remove any references to the package from your code :-)

  5. Run “composer update”

  6. Manually delete the published files

http://stackoverflow.com/questions/23126562/how-to-remove-a-package-from-laravel-using-composer



Uninstall Laravel package

Free PHP obfuscator

PHP Obfuscator


https://github.com/naneau/php-obfuscator


This is an “obfuscator” for PSR/OOp PHP code. Different from other obfuscators, which often use a (reversible) eval() based obfuscation, this tool actually parses PHP, and obfuscates variable names, methods, etc. This means is can not be reversed by tools such as UnPHP. This library was written out of the need to obfuscate the source for a private library which for various reasons could not be shared without steps to protect the source from prying eyes. It is not technically feasible to “encrypt” PHP source code, while retaining the option to run it on a standard PHP runtime.


install: git clone https://github.com/naneau/php-obfuscator , composer install


Run: path//php-obfuscator$ ./bin/obfuscate obfuscate input output


input, output – direcories in the php-obfuscator folder.


 



Free PHP obfuscator