Friday, October 29, 2010

Remote virtual host testing without a DNS server

Assume 184.1.1.1 is the IP of your server.
Assume mywebsite.com is one of the domains your hosting on your server.

----------------------
- On Local Machine
----------------------
#sudo vi /etc/hosts
Add this to the bottom

184.1.1.1 mywebsite.testing


----------------------
- On Server
----------------------
#vi /etc/hosts
Add this to the bottom

184.1.1.1 mywebsite.com mywebsite.testing


#vi /etc/httpd/conf.d/vhosts.conf
Add this virtual host entry

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/vhosts/mywebsite.com/httpdocs
ServerName mywebsite.com
ServerAlias www.mywebsite.com mywebsite.testing

<Directory "/var/www/vhosts/mywebsite.com/httpdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


#service httpd restart



You should now be able to put mywebsite.testing in your browser and be
directed to the appropriate vhost.

Friday, August 13, 2010

How to migrate your AIR certificate (Air 2.0)

1] Determine your application's current publisher ID. In an installed application, this is found in the package's META-INF/AIR/publisherid file.

2] Open your application's descriptor file, e.g. My-App.xml and add in:
<publisherID>mypublisheridstringfoundinabovefile</publisherID>

3] Export a release build with your new certificate

4] Run this command to tell adt you are migrating from a old certificate:
#/Applications/Adobe\ Flash\ Builder\ 4/sdks/4.1.0/bin/adt -migrate -storetype pkcs12 -keystore ./src/MYOLDCERT.p12 -storepass MYCERTPASS -keypass MYCERTPASS my-app-v2.air my-app-v2-migrated.air

Point your application's updater to my-app-v2-migrated.air and it should update fine

Tuesday, August 3, 2010

TLF Bugs

I recently ran into a couple hard to diagnose TLF bugs, this might help save someone else a couple days of debugging time..

1] Redraw bug when using Linked Containers
http://forums.adobe.com/message/2782649#2782649

2] Embedded fonts break if your program uses spark text containers
http://marcel-panse.blogspot.com/2010/03/embedded-fonts-in-tlf-and-swfcontexts.html

Thursday, July 29, 2010

Speed up Flash Builder 4 compile times

1] If your project has multiple application targets, everytime the project rebuilds it rebuilds every application in your project. So if you have 4 targets, things can get slow fast. To remedy this, right click your project, click Properties, goto Flex Applications, and remove the applications your not currently running. Set the remaining application as default.

2] If your project has many files, when the project rebuilds it will copy them into the bin-debug folder which could take a long time, Right click your project, click Properties, click Flex Compiler, uncheck Copy non-embedded files to output folder. You will have to copy files to the bin-debug folder manually if any assets are required.

Saturday, October 24, 2009

Pagination pagelinks PHP algorithm

If you are making a pagination with adjacent links and are trying to figure out how to find out which number the links should start at, the algorithm below should help.

Case 1
Not enough pages, just show them all..
if (totalPages < adjacent*2)
[1]-2-3-4

Case 2
Almost at start, just start showing from beginning
true when currentPage - adjacent < 1
1-[2]-3-4-5-6 ..
starti = 1

Case 3
Almost reached the end, start showing till reached end
true when currentPage + adjacent > totalPages-1
.. 6-7-8-9-[10]-11
starti = currentPage-adjacent*2+(totalPages-currentPage)

Case 4
Not close to end or start, show even number of adjacent links on each side
true when none of above cases match
.. 2-3-[4]-5-6 ..
starti = currentPage-adjacent;


if ($this->totalPages <= $this->adjacent*2) {
$starti = 1;
$endi = $this->totalPages;
}
else if ($this->currentPage - $this->adjacent < 1) {
$starti = 1;
$endi = $this->adjacent*2;
}
else if ($this->currentPage + $this->adjacent > $this->totalPages-1) {
$starti = $this->currentPage - $this->adjacent*2 + ($this->totalPages-$this->currentPage);
$endi = $this->totalPages;
}
else {
$starti = $this->currentPage - $this->adjacent;
$endi = $this->currentPage + $this->adjacent;
}

Wednesday, October 21, 2009

Flash Builder Beta 2

Adobe... who's stupid idea was it to force users to "upgrade" to Beta 2?

If you've been getting this error trying to load a style SWF:
VerifyError: Error #1014: Class mx.modules::ModuleBase could not be found.

at flash.display::MovieClip/nextFrame()
at mx.core::FlexModuleFactory/deferredNextFrame()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\core\FlexModuleFactory.as:574]
at mx.core::FlexModuleFactory/update()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\core\FlexModuleFactory.as:402]
at mx.core::FlexModuleFactory/moduleCompleteHandler()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\core\FlexModuleFactory.as:652]

1] right click the project that contains the CSS file your compiling
2] goto Flex Build Path
3] Change framework linkage to merged
4] Click on the Flex 4.0.0 build path and Remove it
5] Click Add Flex SDK to readd it
6] Click ok to exit and re-clean your project

Hopefully this will fix your compiler bug.

Wednesday, October 14, 2009

Making a whos online script with Zend_Session_SaveHandler_DbTable

1] fetch rows from zend_session table where modifiedtime > time()-900
2] unserialize the data column using this function

function DecodeSession($sess_string)
{
// save current session data
// and flush $_SESSION array
$old = $_SESSION;
$_SESSION = array();

// try to decode passed string
$ret = session_decode($sess_string);
if (!$ret) {
// if passed string is not session data,
// retrieve saved (old) session data
// and return false
$_SESSION = array();
$_SESSION = $old;

return false;
}

// save decoded session data to sess_array
// and flush $_SESSION array
$sess_array = $_SESSION;
$_SESSION = array();

// restore old session data
$_SESSION = $old;

// return decoded session data
return $sess_array;
}

3] print out the username which should be stored in the session data, it'll look
something like
echo $session['data']['Namespace']['user']['username'];

Saturday, October 3, 2009

osx leopard install apache mysql memcache php memcache

1] install ports (similar to fedora's yum)
http://www.macports.org/

Memcached


2] #sudo port install memcached libmemcached

PHP


3] #sudo port install php5-memcache
4] #sudo port install php5-mysql
5] #vi /opt/local/etc/php5/php.ini
make sure socket location is /tmp/mysql.sock

Apache


6] #cd /opt/local/apache2/modules
#sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
[activating module 'php5' in /opt/local/apache2/conf/httpd.conf]
7] #vi /opt/local/apache2/conf/httpd.conf
add these lines:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

find line: DirectoryIndex and append index.php to line

8] #vi ~/.profile
Add this line:
alias httpdstart='sudo /opt/local/apache2/bin/apachectl start'
alias httpdstop='sudo /opt/local/apache2/bin/apachectl stop'

8b] autostart
#sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist

9] #source ~/.profile
10] apachectl start

11] check your http://localhost

MYSQL


12] #sudo port install mysql5-server

follow directions to setup new database
if server is not starting move /etc/my.cnf to /etc/my.cnf.old
13] autostart mysql
#sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
14] edit /etc/my.cnf change socket location to /tmp/mysql.sock

PHPMyadmin


15] #sudo port install phpmyadmin
Update Apache’s httpd.conf file to find phpmyadmin. First add the following lines to the end of the file:

# Local access to phpmyadmin installation
Include conf/extra/httpd-phpmyadmin.conf

and then create a file /opt/local/apache2/conf/extra/httpd-phpmyadmin.conf containing this text:

AliasMatch ^/phpmyadmin(?:/)?(/.*)?$ "/opt/local/www/phpmyadmin$1"


Options -Indexes
AllowOverride None
Order allow,deny
Allow from all

LanguagePriority en de es fr ja ko pt-br ru
ForceLanguagePriority Prefer Fallback






other:
http://trac.macports.org/wiki/howto/MAMP
http://2tbsp.com/content/install_apache_2_and_php_5_macports

Friday, October 2, 2009

OSX make iso shell script

Makes a ISO file while removing .DS_Store files

#!/bin/sh
#echo $1 $2
find "$2" -name .DS_Store -exec rm -rf {} \;
hdiutil makehybrid -o "$1" "$2"

Monday, September 28, 2009

FIOS reboot ONT

I was having trouble with my FIOS ON DEMAND being choppy pixelated and my FIOS internet dropping the connection frequently. Several calls to Verizon support yielded absolutely nothing (TERRIBLE).

I hard reloaded the router, changed the cables, and splitters. NOTHING.

After looking around on the internet to see what else could cause this, I found out it could be the ONT which tech support never even mentions, not to mention the fact that they wouldn't even send a technician out to come check it. Turns out a cold reboot (removing power to the ONT while temporarily disabling battery power) was the cure to both problems.

Follow this guide if you want to give it a try:
•Disconnect the AC from the Power Supply Unit (PSU).
•Remove one lead from the battery in the Battery Backup Unit (BBU).
•Wait one minute.
•Reconnect the battery lead.
•Reconnect AC to the PSU.
taken from: http://www.dslreports.com/faq/16357

The top cover can be opened on the left side. The battery lead looks similar to a PSU's 4 pin connectors, it's on the left of the battery connected to the red wire.

Hope this information helps you, but do anything at your own risk, I take no responsibility for this information.

Thursday, June 25, 2009

Backing up your boot drive on Fedora with dd

This is especially useful for people whose installation have a boot partition and software raid partition on the same drive.
Example Installation:
/dev/sda1 /boot
/dev/sda2 swap
/dev/sda3 raid member

/dev/sdb1 raid member

/dev/md0 / devices=/dev/sda3,/dev/sdb1

If your boot drive fails, your computer will be unable to boot. Here, I will explain
how to backup the boot drive so you can get it up and running very quickly again.

--------------------------
BACKUP PROCEDURE
--------------------------
1] Use dd to save the first 512 bytes of data which contain the drive's MBR (master boot record) and partition info.
# dd if=/dev/sda of=/backup/dd/sda-mbr.img bs=512 count=1

2] Use dd to image the partition containing the boot files(#fdisk says /dev/sda1 contains /boot in my case) as well.
# dd if=/dev/sda1 of=/backup/dd/sda1.img bs=64K

--------------------------
RESTORE PROCEDURE
--------------------------
1] Boot with fedora rescue CD

2] First we have to restore our RAID device.
#echo DEVICE partitions > /etc/mdadm.conf
#mdadm --examine --scan >> /etc/mdadm.conf
#mdadm --assemble --scan /dev/md0

3] Now we have to mount it somewhere
#mkdir /mnt/sysimage
#mount /dev/md0 /mnt/sysimage

4] Restore the MBR and partition info to /dev/sda first.
# dd if=/mnt/sysimage/backup/dd/sda-mbr.img of=/dev/sda
Confirm partitions were restored
# fdisk -l

5] Restore the partition containing the boot files.
# dd if=/mnt/sysimage/backup/dd/sda1.img of=/dev/sda1
Confirm boot files were restored
#mkdir /boot
#mount /dev/sda1 /boot
#ls /boot

6] The boot drive should be good now, it's time to see if it works.
#reboot

7] If your OS boots, it's time to re-add the raid member to the array.
#mdadm --manage /dev/md0 --add /dev/sda3

Monday, May 11, 2009

PureMVC vs Cairngorm framework comparison

Reasons to use PureMVC over Cairngorm.

#1 IMO if your gonna use Cairngorm your better off just going ahead and skipping every framework concept and just making classes with static (global) variables. That's what it feels like to me anyway lol.

#2 Makes it too easy for you to be sloppy. Accessing your model locator everywhere in your app can get ugly fast. PureMVC has a very structured but flexible way to code. Once you get comfortable with PureMVC, you will be able to get up to speed in other projects coded with PureMVC much quicker than Cairngorm coded projects.

#3 If your just starting to try to learn Cairngorm and find it confusing, it's cause you can't make sense of something that doesn't make sense!

#4 It's difficult to make a modular program in Cairngorm. Since the controller/models are singletons only one instance can exist (thus only one instance of the application). There are ways to get it to work, but you're gonna have to think outside the box for that..
PureMVC Multicore provides a framework for creating modular applications right out of the box.

#5 PureMVC utilities. The PureMVC community has added more capabilities on top of the PureMVC framework such as Undo/Redo (works great BTW), Pipes, etc.

#6 Scalability. It just gets way too messy trying to make a complex Cairngorm application. It can especially happen if you're just beginning at it or have been coding lazily. Because coding in PureMVC is much more structured, you won't be held back in the late game.

#7 PureMVC is fun to program in. Cairngorm is a nightmare :P

#8 Views can actually be reused in PureMVC. It's hard to do this in Cairngorm with all the views accessing directly to the global variables in the models. The reason PureMVC can decouple the view from the model is it has something called Mediators which take care of displaying and interaction in the views.

#9 Cairngorm is Adobe's official framework, and Adobe has been pissing me off lately with all the bugs I keep running into :P

p.s. Sorry for the long rant :P

Friday, May 1, 2009

HSlider as scrubber bar showing percent downloaded

If you are making a simple video component with VideoDisplay and want
to use the HSlider as the scrubber bar, you might run into the problem
of trying to display the % of the video that has been downloaded.

We can use HSlider's showHighlightTrack property for that. But
first we have to figure out how we can set it programmatically.

Heres how:


package com.flexas3.components
{
import mx.controls.HSlider;
import mx.core.Container;
import mx.core.IFlexDisplayObject;
import mx.core.mx_internal;
import mx.styles.ISimpleStyleClient;

use namespace mx_internal;
public class HSliderProgress extends HSlider
{
[Bindable]
private var _progress:Number = 0;
public function get progress():Number {
return _progress;
}
// 0-1
public function set progress(o:Number):void {
if (o < 0) o = 0;
if (o > 1) o = 1;
_progress = o;
}


/**
* @private
*/
override mx_internal function drawTrackHighlight():void
{
var track:IFlexDisplayObject = innerSlider.getChildAt(0) as IFlexDisplayObject;
var highlightTrack:IFlexDisplayObject = innerSlider.getChildAt(1) as IFlexDisplayObject;

if (track && highlightTrack)
{
var xPos:Number;
var tWidth:Number;

xPos = track.x;
// minus xPos is the right side offset
tWidth = track.width*progress;
//trace('track.width', track.width, 'tWidth', tWidth);
highlightTrack.move(xPos, track.y + 1);
highlightTrack.setActualSize(tWidth > 0 ? tWidth : 0, highlightTrack.height);
}
}

}
}


When you instantiate the HSliderProgress make sure to set
showHighlightTrack="true".

Also, as you get your video net_status updated just bind the
bytesLoaded/bytesTotal to the progress property.

Also one nice thing is that you can style it the way you'd normally style HSlider with Flex skinning.

Monday, January 19, 2009

Getting Zend Debugger to work with XAMPP Leopard with Zend Studio

1] Copy the Zend Debugger PHP Extension from Zend Studio to your webserver's PHP extension dir.


#cp '/Applications/Zend/Zend Studio for Eclipse - 6.1.0/plugins/org.zend.php.debug.debugger.macosx_5.2.14.v20080602/resources/php5/ZendDebugger.so' /Applications/xampp/xamppfiles/lib/php/php5/extensions/no-debug-non-zts-20060613/ZendDebugger.so


2] edit XAMPP's php.ini to include the extension (#sudo mate /Applications/xampp/etc/php.ini)


;extension=ZendDebugger.so
zend_extension=/Applications/xampp/xamppfiles/lib/php/php5/extensions/no-debug-non-zts-20060613/ZendDebugger.so
zend_debugger.allow_hosts=127.0.0.1
zend_debugger.expose_remotely=always

Sunday, January 18, 2009

Getting started with Unit Testing in your Zend Framework application Leopard

Hello, this guide is for someone who has no idea how to get started writing unit tests inside the Zend Framework application. I don't claim this to be the right way to do it, but its a step in the right direction for me.


Step 1] Install pear and PHPUnit



Here are the steps I used in Leopard.

First install PEAR:


#cd /tmp
#curl http://pear.php.net/go-pear > go-pear.php

#sudo php -q go-pear.php

press enter, choose option 1 the prefix directory as "/usr/local" this will install the pear executable to /usr/local/bin/ and the PEAR files to /usr/local/PEAR

After the install finishes try typing:

#pear


If it doesn't work, the install failed or the $PATH variable doesn't include the /usr/local/bin dir.


Next, install PHPUnit using pear:


#sudo pear channel-discover pear.phpunit.de
#sudo pear install phpunit/PHPUnit

If it gives you any warnings about folder permissions you might have to do something like #sudo chmod 777 the temp dir or wherever its complaining about.


Once pear installs PHPUnit try running it in the commandline

#phpunit


It should run ok. If you get any warnings you will have to look at your php config file.


If your php.ini isnt located in /etc/php.ini you'll have to create a symbolic link as such. For example, I develop using XAMPP so my php config is in /Applications/xampp/etc/php.ini.


#ln -s /Applications/xampp/etc/php.ini /etc/php.ini


Next edit /etc/php.ini to make sure the include_path to PHPUnit is correct


#sudo mate /etc/php.ini


Mine looks something like this.
include_path = ".:/php/includes:/usr/local/PEAR:/usr/local/PEAR/PHPUnit"


Try running PHPUnit again in the command line.

#phpunit


If it doesn't give any warnings, move on to step 2.


Step 2] Create the /tests and /tests/myapp folders.



Your Zend project structure should look something like this:


/myapp/
/myapp/application/
/myapp/application/controllers/
/myapp/application/models/
/myapp/application/views/
/myapp/application/views/scripts/
/myapp/library/
/myapp/library/Zend/
/myapp/tests/
/myapp/tests/myapp/



Step 3] Create the /myapp/application/controllers/IndexControllerTest.php file



This file is to test the IndexController.



class MyApp_public_IndexControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
{

public function setUp()
{
$this->bootstrap = APPLICATION_PATH . '/bootstrap.php';
parent::setUp();
}

/**
* Tests FooController->barAction()
*/
public function testIndexAction()
{
// TODO Auto-generated FooControllerTest->testBarAction()

$this->dispatch ( '/index/index' );
$this->assertController ( 'index' );
$this->assertAction ( 'index' );
}
}


Step 4] Create the /myapp/tests/myapp/AllTests.php file






define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application/'));

set_include_path(
APPLICATION_PATH.'/../library'
. PATH_SEPARATOR . get_include_path()
);


if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'MyApp_AllTests::main');
}

require_once('Zend/Test/PHPUnit/ControllerTestCase.php');

require_once APPLICATION_PATH . 'controllers/IndexControllerTest.php';

class MyApp_AllTests
{
public static function main()
{
PHPUnit_TextUI_TestRunner::run(self::suite());
}

public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('All Tests - MyApp');


$suite->addTestSuite('MyApp_public_IndexControllerTest');

return $suite;
}
}

if (PHPUnit_MAIN_METHOD == 'MyApp_AllTests::main')
{
MyApp_AllTests::main();
}



Step 5] Run AllTests.php



Open the terminal and navigate to the folder where you created AllTests.php


#cd XYZ/myapp/tests/myapp/
#phpunit AllTests.php

PHPUnit 3.3.10 by Sebastian Bergmann.

.

Time: 0 seconds

OK (1 test, 2 assertions)



Hope this started you off okay. Goodluck!


P.S.

Leopard's included PHP does not have PDO_Mysql included by default.
In your Zend_Config_Ini you can use mysqli instead.

Example /application/config/app.ini

[production]
webhost = www.awebsite.com
database.adapter = pdo_mysql
database.params.host = localhost
database.params.username = auser
database.params.password = apassword
database.params.dbname = adatabase

[development : production]

[testing : production]
database.params.dbname = adatabase
#leopard's compiled php doesn't have PDO_MYSQL
database.adapter = mysqli

Thursday, January 15, 2009

Setting up Trac with Plesk

If your running a Plesk server and want to get trac running with mod_python, heres what I did to get them running nicely.

This tutorial assumes you have already installed Subversion, Trac, and that running your Trac daemon was successful.

Setup the trac subdomain in plesk:

1] Create a subdomain 'trac'
2] important: make sure python is unchecked->DISABLED (wierd i know!)

Creating a new project:

#trac-admin /disk1/trac/mynewproject initenv
#mkdir /disk1/trac/mynewproject/.egg-cache
#chmod 777 /disk1/trac/mynewproject/.egg-cache
#chmod -R 777 /disk1/trac/mynewproject/db
#chmod -R 777 /disk1/trac/mynewproject/attachments



Adding a new user:
#htpasswd /disk1/trac/.htpasswd mynewusername


Editing user permissions:
http://trac.edgewall.org/wiki/TracPermissions
If there are no trac admins yet, you must create one in the shell
an example:

#trac-admin /disk1/trac/myproject permission remove anonymous BROWSER_VIEW
#trac-admin /disk1/trac/myproject permission add auser TRAC_ADMIN


Editing trac vhost file:
Please note the PythonPath, your may be different. try typing #find -name trac to find the folder thats similar to mine.

#emacs /var/www/vhosts/yourdomain.com/subdomains/trac/conf/vhost.conf for the new location
example:

<location "/mynewproject">
# SetHandler mod_python
SetHandler python-program
# PythonDebug on
PythonPath "['/usr/lib/python2.4/site-packages/'] + sys.path"
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv /disk1/trac/mynewproject
PythonOption TracUriRoot /mynewproject
</location>
<location "/mynewproject/login">
AuthType Basic
AuthName "WillInteractive Trac Server"
AuthUserFile /disk1/trac/.htpasswd
Require valid-user
</location>


Restart your apache server
#service httpd restart

Next try to access it in your browser at:
http://yourdomain.com/mynewproject


Monday, January 12, 2009

Improving performance in your Flex Applications

Do you understand a day in the life of a Flex component (creation, initialization, invalidation/validation)? Have you heard of how Flex components have to run around this "elastic racetrack" (code execute/render) and how Flex components are structured to run optimally around this racetrack?

When extending a Flex component you need to know these things in order for your component to achieve the best performance possible.

Check out this Adobe Max presentation titled "Creating New Components in Flex 3" by Deepa Subramaniam (you wont be disappointed :P):
http://tv.adobe.com/#vi+f15384v1002

Wednesday, September 17, 2008

Setup Eclipse PDT a PHP IDE with Zend Debugger easily!

So, Dreamweaver was a good editor, but if you have a big PHP project, you will need some more firepower. I decided to install Eclipse PDT a PHP IDE with the Zend Debugger. I used WAMP as my webserver and firefox as my external browser.

I haven't used it yet but I have a feeling it will help speed up development :)

Here are the steps:

Step 1] Download and install Eclipse PDT 1.0.3 (Release) (example: C:\Program Files\PDT\)
http://download.eclipse.org/tools/pdt/downloads/release.php?release=R20080603

Step 2] Download and install WAMP or any server with PHP.
http://www.wampserver.com/en/download.php

Step 3] Download and install Zend Debugger (put the ZendDebugger.dll in your C:\wamp\php\ folder)
http://downloads.zend.com/pdt/server-debugger/
Put the dummy.php in your PHP project's webroot.

Step 4] open up C:\wamp\php\php.ini
change: implicit_flush = Off to implicit_flush = On
change: output_buffering=4096 to output_buffering = Off
at the bottom append:
[Zend]
zend_extension_ts = "C:\wamp\php\ZendDebugger.dll"
zend_debugger.allow_hosts=127.0.0.1/32, 192.168.0.0/255.255.0.0
zend_debugger.expose_remotely=always

Step 5] Install Subclipse by opening PDT goto Help->Find and Install Updates(optional)
Add remote server with URL: http://subclipse.tigris.org/


--------- Extra steps to start debugging with firefox (optional, sorry its a little rough, but these are just general steps) ------------
Step 1] Start PDT, goto Window->Preferences->General->Web Browser, select use external web browser, select firefox
Step 2] Make a new project, make a new file called index.php, right click on the file, goto run as, open run as dialog.
Step 3] Point WAMP to the new project (ex: http://helloworld)
Step 4] Go back to PDT, under PHP Web Page, create new. Under Name: write in Test index.php. Under Server Bugger use: Zend Debugger. On PHP server, make a new one pointing to http://helloworld Under file, manually type in index.php. URL should be left at auto generate.
Step 5] Goto the common tab, check Debug and Run under 'display in favorites menu'. Click apply settings.
Step 6] Edit index.php to do something like echo 'hello world';
Step 7] At the top toolbar if you click the debug arrow you should see test index.php in your favorites, click it. Firefox should popup while PDT is connected to the zend debugger.

Wednesday, September 10, 2008

CakePHP 1.19 Test Suite testing with Session Component

Hello, you might be having a tough time doing some integration testing on your controllers which use the Session component. Here are is an example to help you get started:


class Foo_ControllerTest extends UnitTestCase
{
function test1()
{

$usersController = &new UsersController();
$usersController->_initComponents();
$usersController->constructClasses();
$this->assertNotNull($usersController->Session);
$usersController->Session->_checkValid();

}
}


This creates the model + components in your controller. The sessions should be working normally now.

Take at look at this to see how they did unit testing on the Session component itself for more ideas (https://trac.cakephp.org/browser/branches/1.2.x.x/cake/tests/cases/libs/session.test.php?rev=7246).

Tuesday, September 9, 2008

cakephp 1.19 AppModel bug?

I've been using the $hasMany, $uses, etc properties in the AppModel to simply some of the querying operations. But it seems like sometimes it randomly deletes rows from some of the tables I've specified in the tables. Also, I don't always need to use those associations.


I've found that loading the model and using it as needed seemed like a better approach and it wasn't deleting data from tables mysteriously anymore..

To use another model only when you need it do something like this:


function amodelmethod()
{
loadModel('FooModel');
$fooModel = &new FooModel();
$fooModel->fooMethod();
}