Disable symfony web debug for controller action

\sfConfig::set(’sf_web_debug’, false);

Helpful when running upload in dev ENV.

xdebug zend server mac os x

1. Switch off:
1.1 Zend Optimizer
1.2 Zend Data Cache

2. Stop apache

zendctl.sh stop-apache

3. Download or compile xdebug and put it into

/usr/local/zend/lib/php_extensions

4. Add config into php.ini

/usr/local/zend/etc/php.ini

zend_extension="/usr/local/zend/lib/php_extensions/xdebug.so"

[xdebug]
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.show_local_vars=On
xdebug.var_display_max_data=10000
xdebug.var_display_max_depth=20

5. Start apache

zendctl.sh start-apache

Compiled xdebug

Source: http://akrabat.com/php/some-notes-on-zend-server-ce-for-mac-os-x/

In case you get such a warning:

PHP Warning:  Module 'Zend Data Cache' already loaded in Unknown on line 0
PHP Warning:  Zend Extension Manager: Cannot load Zend Data Cache module in Unkn
own on line 0
PHP Warning:  Module 'Zend Utils' already loaded in Unknown on line 0
PHP Warning:  Zend Extension Manager: Cannot load Zend Utils module in Unknown o
n line 0

Just put xdebug config piece above zend extension manager configuration.

[zend]
zend_extension=/usr/local/zend/lib/ZendExtensionManager.so

NetBeans PHPUnit_Framework_Exception: Could not connect to the Selenium RC server

As I presume selenium that comes with NetBeans Selenium plugin not best one.

To Fix:

  1. Download last selenium RC
  2. In Netbeans services tab stop Selenium server
  3. Find out selenium-server-2.0.jar in netbeans settings folder (Mac OS X - .netbeans/7.0/modules/ext/selenium/selenium-server-2.0.jar)
  4. Replace it with downloaded one
  5. Start Selenium server in NetBeans

Happy testing

WSO2 WSF PHP installation issues

Since WSO2 WSF PHP is the only library that supports file attachements and WSDL generation we decided to stick on this.

That was really hard to compile and have it working, may be because of we tried to do that on Mac OS.

  1. Download and extract WSO2 WSF PHP in right place initially since it use initial sources(you will need to keep them) after compilation and I had lot of problems in order to move it and finally decided to recompile.
  2. link gcc to gcc-4.0 instead of 4.2 (sudo ln -fs /usr/bin/gcc-4.0 /usr/bin/gcc)
  3. ./configure MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS=”-arch i386 -g -Os -pipe -no-cpp-precomp” CCFLAGS=”-arch i386 -g -Os -pipe” CXXFLAGS=”-arch i386 -g -Os -pipe” LDFLAGS=”-arch i386 -bind_at_load” ‘CPPFLAGS=-DHAVE_GETIFADDRS’
  4. If you will not specify php extension path during ./configure it will take default one using php-config. If you are running Zend Server CE than it will be problem for you since compilation somehow link your .so to initial compilation place. (You could also symlink php-config to zend/bin/php-config as we did in our case).
  5. make, sudo make install - this will compile wsf.so and wsf_c and will put them into zend/lib/php_extensions folder
  6. You will need to point wsf.home to zend/lib/php_extensions/wsf_c (my one looks like this /usr/local/zend/lib/php_extensions/wsf_c) - it was not working for me until I set wsf.home
  7. Restart Apache
  8. Use samples/ located in initial source package in order order to test WSF PHP. You could copy them in any place, and they will work.
  9. You will need to put wso2-wsf-php-src-2.1.0/scripts into include_path in order to have WSDL generation working.
  10. WSDL generations was not working for me even after showing scripts folder in include path and after an hour I figured out that It’s not looking into wsf.php (which is located in scripts folder executed in strange way so that it’s not able to see scripts in include path)
    In function ws_generate_wsdl() it tries to require few files to generate ( WSDL require_once(”wsdl/WS_WSDL_Creator.php”); ). I have it working after setting full paths in all require_onces in this function.

Mac to windows/ubuntu adhoc internet sharing

Mac to Ubuntu adhoc

1. System Preferences -> Sharing -> Internet Sharing -> AirPort -> AirPort Options

Chanel: Automatic

WEP: Enabled

Password: 13 symbol anything (I used 9 letters and 4 numbers)

WEP key length: 128-bit

2. Save and start sharing. (This should create network)

3. Ubuntu -> Find network clicking on WiFi icon

4. Connect to using that key (key type should be 128 passphrase and not 40/128)

5. Goto Network Connections -> Wireless Tab -> Edit connection -> Security -> Switch from Open to Shared

6. Reconnect

For windows see: http://hintsforums.macworld.com/showthread.php?t=79326

Zend Server on Ubuntu

Zend Debugger
Zend Core comes complete with the option to enable remote PHP debugging and profiling of Web applications.
Source: http://files.zend.com/help/Zend-Core/studio_server.htm

Zend Server
sudo vim /etc/apt/sources.list
add “deb http://repos.zend.com/zend-server/deb server non-free”
wget http://repos.zend.com/zend.key -O- |apt-key add -
aptitude update
aptitude install zend-server-php-5.3
Source: http://files.zend.com/help/Zend-Server/zend-server.htm#deb_installation.htm

Zend_Form with Zend_Validate with Zend_File_Transfer

How to build form using ini files.
Example includes Zend_Form elements, Zend_Validate and File uploads using Zend_File_Transfer.

Protected method to retrieve form config and fill data into selectbox.

protected function prepareProductForm()
{
$form = new Application_Form( ‘admin/product’ );

$categories = array( ‘Select Category’ );
foreach( Application_Category::getCategories() as $category )
{
$categories[$category->categoryId] = $category->name;
}

$form->getElement( ‘categoryId’ )->setMultiOptions( $categories );

return $form;
}

This method will render form from and handle submits. Will check for uploaded files.

public function productAction()
{
$form = $this->prepareProductForm();
$product = array();

if ( $this->getRequest()->isPost() )
{
$product = new Application_Product(
array(
‘productId’ => $this->getRequest()->getParam( ‘productId’ ),
‘name’ => $this->getRequest()->getParam( ‘name’ ),
‘description’ => $this->getRequest()->getParam( ‘description’ ),
‘categoryId’ => $this->getRequest()->getParam( ‘categoryId’ ),
‘resellerPrice’ => $this->getRequest()->getParam( ‘resellerPrice’ )
)
);

if ( !$form->isValid( $this->getRequest()->getPost() ) )
{
$this->view->errorMessages = array( “Validation Error” );
}

/*
* Receiving files
*/
if ( !$form->photos->receive() || !$form->photom->receive() || !$form->photol->receive() )
{
$this->view->errorMessages = array( “Upload error” );
}

if ( count( $this->view->errorMessages ) <= 0 )
{
try {
$product->save();
$this->view->message = “User successfully updated”;
}
catch ( Application_Service_Exception $ex )
{
$this->view->errorMessages = array( $ex->getMessage() );
}
}

$product = $product->toArray();
}
elseif ( $this->getRequest()->getParam( ‘id’ ) )
{
$product = Application_Service::getInstance()->getProduct( $this->getRequest()->getParam( ‘id’ ) );
}

$form->populate( $product );
$this->view->form = $form;
}

Ini file defining form containing elements.

# Product

admin.product.method = post
admin.product.options.description = ‘Create Product’

admin.product.elements.productId.type = hidden

admin.product.elements.name.type = text
admin.product.elements.name.options.label = “Product Name”
admin.product.elements.name.options.required = true

admin.product.elements.photos.type = file
admin.product.elements.photos.options.label = “Photo S”
admin.product.elements.photos.options.description = “( 100×110 ) Shown on Front page. Only jpg,png,gif formats supported”
admin.product.elements.photos.options.destination = APPLICATION_PATH “/../public/images/product”
admin.product.elements.photos.options.validators.extension.validator = Extension
admin.product.elements.photos.options.validators.extension.options.extension = “jpg,png,gif”
admin.product.elements.photos.options.validators.imagesize.validator = ImageSize
admin.product.elements.photos.options.validators.imagesize.width = 100
admin.product.elements.photos.options.validators.imagesize.height = 110

admin.product.elements.photom.type = file
admin.product.elements.photom.options.label = “Photo M”
admin.product.elements.photom.options.description = “( 180×250 ) Shown on Auction Info Page. Only jpg,png,gif formats supported”
admin.product.elements.photom.options.destination = APPLICATION_PATH “/../public/images/product”
admin.product.elements.photom.options.validators.extension.validator = Extension
admin.product.elements.photom.options.validators.extension.options.extension = “jpg,png,gif”
#admin.product.elements.photom.options.validators.imagesize.validator = ImageSize
#admin.product.elements.photom.options.validators.imagesize.options.width = 180
#admin.product.elements.photom.options.validators.imagesize.options.height = 250

admin.product.elements.photol.type = file
admin.product.elements.photol.options.label = “Photo L”
admin.product.elements.photol.options.description = “( 250×450 ) Shown on … Only jpg,png,gif formats supported”
admin.product.elements.photol.options.destination = APPLICATION_PATH “/../public/images/product”
admin.product.elements.photol.options.validators.extension.validator = Extension
admin.product.elements.photol.options.validators.extension.options.extension = “jpg,png,gif”
admin.product.elements.photol.options.validators.imagesize.validator = ImageSize
admin.product.elements.photol.options.validators.imagesize.width = 250
admin.product.elements.photol.options.validators.imagesize.height = 450

admin.product.elements.description.type = textarea
admin.product.elements.description.options.label = “Description”
admin.product.elements.description.options.cols = 50
admin.product.elements.description.options.rows = 8

admin.product.elements.resellerPrice.type = text
admin.product.elements.resellerPrice.options.label = “Reseller Price”
admin.product.elements.resellerPrice.options.required = true

admin.product.elements.categoryId.type = select
admin.product.elements.categoryId.options.label = “Category”
admin.product.elements.categoryId.options.required = true

admin.product.elements.submit.type = submit
admin.product.elements.submit.options.label = “Save”

Magento 1.4 upgrade - Missing Yesnocustom.php

After upgrade from 1.3.2.4 to 1.4.0.1 using MagentoConnect we got exception in Admin/System page.

After checks we have figured out that the file was missing in upgrade package for Magento Core Modules.

File was used by system.xml located in Mage/Core/etc/.

In order to fix this you have to download Magento package 1.4.0.1 from website and add missing file to your sources

app/code/core/Mage/Adminhtml/Model/System/Config/Source/Yesnocustom.php

Magento :: Invalid mode for clean() method

After upgrade Magento to 1.4.0.1 I’ve got such an error.

The problem is that Varien did not managed to add removal deprecated code/files which overrides Zend’s code.

In order to fix this problem you have to remove folder:

app/code/core/Zend/Cache

Upgrading subversion client to 1.6.x for Ubuntu 8.04 hardy

Tortoise SVN and other IDE integrated subversion clients was changing format of .svn/* files so that was not possible to use command line subversion client which is more secure.

Finally got upgraded subversion client for Ubuntu Hardy (8.04).

1. Copy source list from: https://launchpad.net/~anders-kaseorg/+archive/subversion-1.6

2. Add lists to /etc/apt/sources.list at bottom of file - Save file

3. apt-get install subversion

(Here I had asked to confirm not authenticated installation)

4. svn status