Kurinchi Blogger Scribbles …


Archive for the ‘PHP’ Category

Nov 15
2011

Linux: How to upgrade PHP from 5.1 to 5.2 in CentOS5?

Last updated: November 15th, 2011

First Check PHP version that is currently installed

$ php -version

Check Linux Version

$ cat /etc/*-release (or redhat-release)

Create a repo file with the content given below. As you can note, we are looking for package upgrade related to php only.
(more…)

Mar 06
2011

Zend Framework: Simple steps to create Action Helper

Last updated: August 21st, 2011

Action helpers in Zend controller helps in abstracting concepts that are in common use for the project without cluttering the code base.

Zend’s official website and Zend casts gives detailed easy to use examples.

Step 1: Decide where you want the helper class for the controllers to reside inside the application folder. For this example, let us create a folder hierarchy under “application” folder

» application/controllers/Helper
(more…)

Jan 26
2011

PHP Excel reader

Last updated: January 26th, 2011

php-excel-reader Parse and retrieve information from XLS files

Download from Code Google

When the excel reader is run on PHP 5.3, below mentioned deprecated warning messages gets shown.

i) Assigning the return value of new by reference is deprecated

Remove & from the line below

$this->_ole =& new OLERead();

and have

$this->_ole = new OLERead();

instead.

ii) Function split() is deprecated

Function split() is deprecated and we can use explode() instead of that.

$parts = split(“;”,$format);

change it to

$parts = explode(“;”,$format);

Oct 29
2010

How to configure Zend Framework in windows?

Last updated: May 29th, 2011

Steps to configure Zend Framework in windows

i) Check if the path to PHP executable is set. You can check this by executing php -version from command prompt.

ii) Move zf.bat (or zf.sh) and zf.php which will be present in the Zend Framework’s bin folder to the php’s bin folder (where php.ini resides)

iii) Move \path\to\znedframework\library to the location identified by “include_path” variable

One way to identify the include_path variable
-> php -i

Other way is to open the php.ini file to identify the location. You can also append the path to zend framework’s library to the include path variable within php.ini file.

For Windows users, you can add an environment variable (system variable) that would point to the Zend Framework’s library folder and name the variable “ZEND_TOOL_INCLUDE_PATH”

If the configuration has been done correctly then you should be able to get a positive response when you execute

-> zf show version
-> zf –help

Aug 02
2010

PHP: ‘Fatal error: Allowed memory size of 8388608 bytes exhausted’

Last updated: December 30th, 2010

Reason why you see this message is due to PHP memory leakage. PHP is trying to load a large image or file into memory and is not finding enough space for it to load.

If you think, that you will need the necessary feature to upload large files then there are two ways by which you can enable this feature.

i) Edit the physical file and have the line
ini_set(“memory_limit”,”20M”);

ii) Edit php.ini and add the following line. You need to restart the apache/IIS server once php.ini file is modified.
memory_limit=32M

Mar 29
2010

Zend’s Directory Structure

Last updated: March 30th, 2010

Some factors like host environment setup, multiple projects for single/multiple clients, common helpers, cross-functionality between sites etc. determines how the folder architecture needs to be structured. Zend framework offers this flexibility.
(more…)

Mar 25
2010

Setting up Zend Framework – for Beginners

Last updated: March 23rd, 2010

Download the latest version of Zend framework from
http://framework.zend.com/download/latest

At the time of writing it was 1.10.2 available at Zend 1.10.2

$ pwd
/tmp

$ wget http://framework.zend.com/releases/ZendFramework-1.10.2/ZendFramework-1.10.2.tar.gz
(more…)

Nov 11
2009

UTF and Byte Order Mark (BOM)

Last updated: November 11th, 2009

UTF abbr. Unicode Transformation Format is a super set of characters that facilitates the display of characters from ALL languages that is currently in use.

BOM stands for Byte Order Mark (also known as ZERO WIDTH NON-BREAKING SPACE) appearing at the beginning of a data stream to define the byte order (whether it is little endian or big endian). BOM is to indicate that the file is Unicode based.

Possible problem caused by Byte Order Mark
In IE6, it will send the dispaly into quirks mode with its presence before “<DOCTYPE …”

How to check the presence of BOM?
View the source code of the page that does not display correctly in a user agent. Or, open the file in the editor which does not support UTF encoding to see the BOM’s signature on the files.

Suggestion
If the user-agent gives problem when you program for multi-lingual websites, check the editor settings to see what format is being used for saving program files. Notepad++ has the option to convert files to UTF and to UTF without BOM. Use the appropriate settings to convert your files.

A character set related tutorial on W3C site can be found here

Byte Order Mark on Wiki

Article on PHP and UTF

Oct 10
2009

How to include PEAR libraries with CakePHP?

Last updated: October 8th, 2009

Suggested solutions from other sites:
1) Modify /config/paths.php
2) Create separate php.ini settings file with the path to PEAR library
3) Modify the app_controller.php with the PEAR path settings

My preference is to add the PEAR library to the “vendors” folder and to modify the app_controller to have the PEAR path included through it.

if( file_exists(VENDORS.’Pear’)){
ini_set(‘include_path’, ini_get(‘include_path’) . PATH_SEPARATOR . PEAR);
}

Above solution suggested at CakePHP’s trac

Depending on the library that you want to get included in the programs, add the library to the respective view

App::import(‘vendor’, ‘XML_Feed_Parser’, array(‘file’ => ‘../vendors/pear/XML/Feed/Parser.php’));

Oct 09
2009

PHP: What is PEAR?

Last updated: November 11th, 2009

PEAR stands for PHP Extension and Application Repository.

To learn more about the PEAR library click here

If you are beginner, the following link will help you tread with the library usage PEAR Manual

Installation instructions clearly walks through the steps for PEAR configuration. There may be cases where you may want to use PEAR libraries for specific projects only in which case you can install PEAR library for that specific purpose. To use it in projects, PEAR path should be set in php.ini settings or should be included in the project configuration’s physical path.


Valid HTML 4.01 Strict  Valid HTML 4.01 Strict