CategoryDevelopment

Web development related information

RIJNDAEL encryption with PHP, 256-bit using IV

I had a bit of trouble finding a how-to of how to encrypt and decrypt using RIJNDAEL, so I put together a quick example of how to using a non-blank IV. However I did find a useful code snippet from Chilkat Software that helped me a lot of the way. The only gotcha I found is that if you generate an RIJNDAEL 256 CBC key and IV using OpenSSL it will generate a 64-bit key and 32-bit IV, even though...

How to install CentOS 6 on Microsoft Hyper-V virtualization

Many developers rely on Linux, but often work in a Windows infrastructure environment. Often it’s not feasible to install a flow-blown VSphere or XenServer setup when everything else runs on Windows Server and there’s limited hardware, but virtualization has many advantages. Enter Hyper-V, which can be looked after by Windows system administrators, but let you use Linux in virtual...

Get Android stack trace from device using Debug Bridge

Instead of crashing, sometimes your Android application will stop responding and dump a stack trace to the device. You probably will not be able to access this using Android File Transfer, and if you view it using the Dalvik Debug Monitor Server (DDMS) the data directory will probably appear empty. You can get the file using the Android Debug Bridge (ADB) however. The easiest way to set this up...

Using ZFDebug for Zend Framework with database and cache

ZFDebug is a Zend Framework plugin to debug and analyse your web application as it bootstraps, so that you can see how long everything takes to load, including how many database and cache calls are made. Having used ZFDebug in the past, it’s a handy tool but somewhat light on documentation. Here is a simple way to set it up to debug your database and cache calls, which should be placed...

Using Zend_Pdf and Zend_Pdf_Image with remote URL’s (files)

Zend_Pdf is a handy component of Zend Framework, but expects you to use local files. However if you need to open files that are located on a different server (such as an Amazon S3 bucket) you will need a way of getting them into Zend_Pdf first. $pdf = Zend_Pdf::load($pdfUrl); One solution is to stream them in via a string… $pdf = Zend_Pdf::parse(file_get_contents($pdfUrl)); Similarly, if...

Copying files in Red Hat/CentOS without prompting, -f –force flag being ignored

Something annoying about Red Hat/CentOS/Fedora I had forgotten after years of Debian, Ubuntu and SuSE (or something that they’ve introduced recently, I’m not sure) is that cp is an alias to cp -i, as in it is interactive by default. Therefore the following will still prompt you for overwriting: cp * -Rf /var/somewhere/new_location To get around this just use the cp binary directly...

Add a Git repository as a package using Composer for PHP

There isn’t much documentation on how to setup PHP libraries using Composer that are not in Packagist; one way to do this is as a package. If you specify the version number of the library (or other code) that you want you can fetch them from zip files, Subversion or Git. This way you don’t need to add any Composer files (such as composer.json) to the library itself, which is handy if...

Install Zend Framework 2 and Doctrine 2 using Composer

Since the installation instructions aren’t overly clear (I don’t find) for how to install more than one package to a project, you need a composer.json that looks akin to the following: { "require": { "doctrine/orm": "*", "zendframework/zendframework": "2.0.*" } } What caught me out is that all the packages you want need to be in the...

Install Composer for PHP with detect_unicode = Off as a php.ini file does not exist

If you are having problems installing Composer, using the method mentioned on their website: curl -s | php You may get an error like the following (which will be because PHP CLI may have a different php.ini or not be present at all) #!/usr/bin/env php Some settings on your machine make Composer unable to work properly. Make sure that you fix the issues listed below and run this script again: The...

Persisting Zend controller variables whilst forwarding actions

Quick tip for when you’re trying to persist variables in a controller using Zend Framework, if you’re using a class property for your action controller then it’s because using the _forward action helper will actually re-instantiate the controller class, so your member variables (properties) will be reset. Thus if you declare them static then they will persist between _forward...