Posts Tagged ‘php’

Running Jenkins CI for PHP on Amazon EC2 [1/7]

October 27th, 2011

To ensure code quality for your PHP application, you might want to use a continuous integration service such as Jenkins CI (previously known as Hudson) to run things like PHPUnit, Code Coverage checks, PHP Mess Detector etc. But how do you install and run this cheaply? This series of 7 “easy to follow” tutorials will let you start and stop an Amazon EC2 “Micro” instance (which is free for your first year using Amazon) for testing.

These posts will be published on a daily basis between the 27th of October and 2nd of November inclusive.

  1. Signing up to Amazon EC2 and starting your first image
  2. Preparing PuTTY for Amazon EC2
  3. Connecting to Amazon EC2 using PuTTY
  4. Installing and Configuring Jenkins CI (this is the big/important post)
  5. Make a backup of the Amazon EC2 configuration
  6. Relaunching the Amazon EC2 image

PHP: Magento – current stock value

August 13th, 2011

If you run the Magento ecommerce shopping cart software and you want to find out how much your stock is worth, how many product lines you have stocked and how many individual items you have, you may find the following MySQL query handy.

I’m assuming that you’ve created an attribute with the attribute code “supplier_price” as a decimal, that you’ve kept this field up to date and your stock levels are accurate 😀 If it isn’t called “supplier_price” change the appropriate part in the query.

COUNT(sku) AS 'products_stocked',
SUM(qty) AS 'items_in_stock',
SUM(stockvalue) AS 'stock_value'

(cataloginventory_stock_item.qty * catalog_product_entity_decimal.value) AS stockvalue
catalog_product_entity.type_id='simple' AND
cataloginventory_stock_item.product_id=catalog_product_entity.entity_id AND
catalog_product_entity_decimal.entity_id=catalog_product_entity.entity_id AND
eav_attribute.attribute_id=catalog_product_entity_decimal.attribute_id AND
eav_attribute.attribute_code='supplier_price' AND
cataloginventory_stock_item.qty > 0

PHP Profilers – A Quick summary

December 29th, 2009

More an aid to memory then anything, here’s the PHP profilers I’ve recently heard about:

XDebug by Derick Rethans
The oldest and most well known profiler. Needs modification of the server’s PHP file to run. Compatible with KCachegrind/WinCacheGrind, MacCallGrind and Webgrind and remote debugging tools. Produces quite large debug files (typically 900Kb to 10Mb compare to XHProf’s 110Kb).
XHProf by Facebook Inc (available via PECL)
Large amount of information provided and allows you to “drill down” by various sections – allows comparison of “diffs” between runs to check performance enhancements. Needs modification of the server’s PHP file to run. Also compatible with the *Grind systems. Used by Facebook and Manga High’s online maths games website, but only currently runs on Linux/FreeBSD. Seems to be preferred by iBuildings (see Profiling with XHProf) which is how I originally heard about it.
PHP Quick Profiler (PQP) by Particle tree
Needs modifications to your PHP code, but does not need the server’s PHP modifying (so it can be used on shared hosting easily). Nice and bright. Used by ParticleTree on their Wufoo product.

PHP: Getting individual packages on Zend Framework

February 22nd, 2009

@binarykitten (on Twitter) had the question I officially give up.. how the hell do you download only 1 component of the Zend Framework? I’ve been looking all over the site and I told her that I wasn’t aware of a method, that there were potential dependencies and to maybe try asking @calevans. He responded with the link which appears to be a packager for the PHP Zend Framework versions 1.6 and 1.7 developed by Jani Hartikainen (@jhartikainen).

So, yes, it is possible to (unofficially) download parts of the Zend Framework and not have to worry about dependences.

Snippet: Parallel Processing in PHP

February 20th, 2009

*snippet* This is just a quick “bookmark” style post to remind me to look at the potential for utilising Parallel Processing in PHP using the “divide and conquer” method which may help in compiling/comparing stats in an application I’m working on.

%d bloggers like this: