WarpConduit Computing

  • Quick Tips
  • Web Development
  • WordPress Plugins
  • Home
  • Passphrase Generator
  • Password Generator
  • About
  • Contact

Quick Tip: Profiling PHP Applications with Xdebug, WinCacheGrind & XAMPP for Windows

September 1, 2012 by Josh Hartman

In today’s quick tip screencast you’ll learn how you can profile a PHP application, such as WordPress, using Xdebug and WinCacheGrind on XAMPP for Windows.

View Screencast

Enabling Xdebug on XAMPP for Windows

To enable Xdebug, modify the following settings in your php.ini configuration file:

  • Uncomment the zend_extension = "\xampp\php\ext\php_xdebug.dll" line
  • Set xdebug.profiler_enable_trigger = 1
  • Set xdebug.profiler_output_name = "cachegrind.out.%u.%H_%R"

Save php.ini and restart Apache.

Resources

XAMPP for Windows
WinCacheGrind

Filed Under: Web Development Tagged With: debug, php, profiling, wincachegrind, windows, xampp, xdebug

How to Enable PHP 5.3 on HostMonster Shared Web Hosting

January 27, 2012 by Josh Hartman

phpinfo

Click image to view full phpinfo() output PDF

You heard it right, you can now run PHP 5.3 applications on HostMonster. I’ve only testing this on HostMonster, but I would assume the same applies to BlueHost.

Simply add this line to the beginning of your website’s root .htaccess file:

AddHandler application/x-httpd-php53 .php

After making this change you can test it using phpinfo() and it will show you the version at the top, and as of the time of this post Hostmonster is keeping right up to date, running version 5.3.9.

This is exciting news for Zend programmers and other PHP developers ready for the upgrade. Enjoy!

 

Filed Under: Web Development Tagged With: htaccess, php

Get File Extension with PHP + Benchmark Results

February 27, 2011 by Josh Hartman

I know you’ve probably seen this topic a hundred times, and so have I, but this one has a different twist.  We already know that there are many ways to get the extension of a file, but which one is the fastest?  That’s what I’m going to address right now.

Contenders

In each of the code examples $file is set to c:\\xampplite\\htdocs\\index.php.

String-to-Array Method


<?php
$ext = end(explode('.', $file));
echo $ext; // outputs 'php'
?>

Sub-String Method


<?php
$ext = substr($file, strrpos($file, '.')+1);
echo $ext; // outputs 'php'
?>

Path Info Method


<?php
$ext = pathinfo($file, PATHINFO_EXTENSION);
echo $ext; // outputs 'php'
?>

Setup

To test each of the contenders I put together a script that timed the execution of 1,000,000 iterations of each command. If you would like the script you can download it here.

Results

Get File Extension PHP Benchmark
Sub-String Method: 0.778156 seconds
String-to-Array Method: 1.889744 seconds
Path Info Method: 2.020036 seconds

Winner

Our winner? The Sub-String Method! Next time you reach for that line of code to get a file’s extension, go for gold, and choose the Sub-String Method.


<?php
$ext = substr($file, strrpos($file, '.')+1);
echo $ext; // outputs 'php'
?>

Filed Under: Web Development Tagged With: benchmark, extension, file, php

Increase Image Upload File Size Limit on OpenCart 1.4.9.3

February 4, 2011 by Josh Hartman

OpenCart’s default image upload size is 300KB and that is simply too small for clients that don’t have the knowledge to resize their images before uploading them. Although uploading digital camera images does use more bandwidth, sometimes it can not be avoided. To adjust the image upload size make the following changes around line 446 of admin/controller/common/filemanager.php:

if ($this->request->files['image']['size'] > 10485760) {
	$json['error'] = $this->language->get('error_file_size');
}

In this case we have increased the upload size limit to 10MB, also make sure that your php configuration will allow file uploads and posts of this size.

Now you have these big images uploaded, but sometimes GD can run out of memory trying to resize these large images. You can solve this by using imagemagick, if available. So what we’re going to do is resize all images larger than 1000×1000 down to 1000×1000. Make the following changes around line 490 of admin/controller/common/filemanager.php:

if (!isset($json['error'])) {	
	if(substr($this->request->files['image']['type'],0,5)=='image'){
		$imageinfo = getimagesize($this->request->files['image']['tmp_name']);
		if($imageinfo[0]>1000 || $imageinfo[1]>1000){
			exec('convert -colorspace RGB "'.$this->request->files['image']['tmp_name'].'" -resize 1000x1000 "'.$this->request->files['image']['tmp_name'].'"');
		}
	}
	if (@move_uploaded_file($this->request->files['image']['tmp_name'], $directory . '/' . basename($this->request->files['image']['name']))) {		
		$json['success'] = $this->language->get('text_uploaded');
	} else {
		$json['error'] = $this->language->get('error_uploaded');
	}
}

That’s it, your image upload file size limit has been lifted and memory usage issues have been dealt with!

Filed Under: Web Development Tagged With: image, limit, opencart, php, size, upload

  • « Previous Page
  • 1
  • 2
  • 3
  • 4
  • 5
  • Next Page »

Connect

  • Facebook
  • GitHub
  • RSS
  • Twitter
  • YouTube

Recent Posts

  • How to Permanently Remove the “Learn about this picture” Spotlight Wallpaper Icon From Your Windows Desktop
  • How to Quickly Test a Fax Machine
  • Extremely Useful Applications for Web Development and IT Tasks

Tags

automatic benchmark bigint class composer css embed escape event font function gzip helper htaccess html htmlspecialchars image increment javascript jquery list magento media mysql number observer opencart order output photo php profiling random redirect rijndael software text type ubuntu url windows windows 7 wordpress xampp xss

Blogroll

  • CodeIgniter
  • Fusion Forward
  • jQuery
  • Nettuts+
  • Smashing Magazine

© 2025 WarpConduit Computing. All Rights Reserved.