Archive for category Zend Framework
Pear not working with MAMP
Posted by Stuart in Zend Framework on September 9, 2011
When running the version of Pear that comes with MAP you may get the following:
Notice: unserialize(): Error at offset 267 of 1133 bytes in Config.php on line 1050
ERROR: The default config file is not a valid config file or is corrupted.
The solution is to delete the conf file, located here (path may vary slightly):
/Applications/MAMP/bin/php/php5.3.6/conf/pear.conf
That’s it.
PHP Debugging in Chrome with ChromePHP
Posted by Stuart in Zend Framework on January 10, 2011
Easy PHP console logging in Chrome (similar to FirePHP in Firefox).
- Download the ChromePHP Extension (you will click this extension “on” when you want to use ChromePHP).
- Download the ChromePHP class itself and stick it in your path (example:
/Applications/MAMP/bin/php5.3/lib/php/ChromePhp.php). - (a most critical step that is not made clear in the ChromePHP install instructions) Create a place for ChromePHP to store log files:
mkdir /Applications/MAMP/htdocs/chromephplogs - Start logging:
include 'ChromePhp.php';
ChromePhp::useFile('/Applications/MAMP/htdocs/chromephplogs', '/chromephplogs');
ChromePhp::log('hello world');
ChromePhp::log($_SERVER);// using labels
foreach ($_SERVER as $key => $value) {
ChromePhp::log($key, $value);
}// warnings and errors
ChromePhp::warn('this is a warning');
ChromePhp::error('this is an error');
Notice the use of ChromePhp::useFile() in the above code… this is critical as ChromePhp simply will not work correctly without it. useFile() accepts 2 arguments… here is the code itself:
/**
* this will allow you to specify a path on disk and a uri to access a static file that can store json
*
* this allows you to log data that is more than 4k
*
* @param string path to directory on disk to keep log files
* @param string url path to url to access the files
*/
public static function useFile($path, $url)
{
$logger = self::getInstance();
$logger->addSetting(self::LOG_PATH, rtrim($path, '/'));
$logger->addSetting(self::URL_PATH, rtrim($url, '/'));
}
OpenVPN Setup tips
Posted by Stuart in Zend Framework on May 24, 2010
To send all traffic over an established VPN connection:
sudo iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
sudo -s echo “1″ > /proc/sys/net/ipv4/ip_forward
sudo openvpn /etc/openvpn/server.conf
SSH Tunneling Tips: Now With More Awesome!
Posted by Stuart in Zend Framework on May 23, 2010
OK, that previous tip was pretty weak. Try this instead. Set up a SOCKS proxy and tunnel it through SSH!
Here’s how:
1. Open the SSH connection…
ssh -ND 8887 -p 22 rufus@83.27.411.896
2. Set your network to point to the proxy. On a Mac that would be…
a. Open Network Preferences…
b. Click Advanced…
c. Click Proxies…
d. Check the SOCKS Proxy box then in the SOCKS Proxy Server field enter localhost and the port you used (8887)
e. OK and Apply and you are done!
p.s. Bonus! You can enable gzip compression by setting the -C flag (ex. ssh -C -ND 8887 -p 22 rufus@83.27.411.896)
SSH Tunneling Tips
Posted by Stuart in Zend Framework on May 23, 2010
To tunnel one, single website over SSH:
ssh -L 8887:google.com:80 -p 22 -l rufus -N 83.27.411.896
Explanation:
The first port, 8887, is the one on your local machine that you are going to point your proxy to….
… next comes the website you are visiting…
… next is the port of the service on the remote computer you will be accessing
Web: HTTP 80
Web over SSL: HTTPS 443
Outgoing email: SMTP 25
Incoming email: POP3 110
Incoming email: IMAP 143
… next comes the port your SSH is set to (default is 22)…
… next is the user you will log in as…
… next is the address of the ssh server you are accessing.
That’s it. But you only gain access to Google. Try to go outside of that and you will get sent back to Google.
Mercurial – pushing changes to a remote site
Posted by Stuart in Zend Framework on April 28, 2010
OK, this was not straight forward but it was mainly because of paths and permissions issues.
My local repository is here: /Applications/MAMP/htdocs/aproj/
On the remote machine I need to get a copy of this so I issue the following:
sudo hg -v clone ssh://me@192.168.1.107//Applications/MAMP/htdocs/aproj/ /var/www/aproj/
This will clone the repository.
After making changes I try to push them from the local repo to the remote server using:
sudo hg push ssh://me@192.168.1.105//var/www/aproj/
but this will fail with the error:
remote: Not trusting file /var/www/aproj/.hg/hgrc from untrusted user root, group root
remote: Not trusting file /var/www/aproj/.hg/hgrc from untrusted user root, group root
remote: abort: could not lock repository /var/www/aproj/: Permission denied
abort: unexpected response: empty string
This stems from the local repo having different owner (and group?) from the remote.
I can, however, do a pull from the remote repo (note I am inside var/www/aproj/:
sudo hg pull
Then update to implement the pulled changes:
sudo hg update
and that gets things working for the time being.
One really weird thing I ran into. on the local machine I can issue a command to mercurial with no problem. For example:
hg info
However, doing that via ssh from the remote server failed with the message that ‘hg could not be found’. The path to hg was set correctly (as evidence by ‘echo $PATH’) but I still had to symlink hg from /usr/bin/ in order to get it to work (from the remote machine… it worked fine locally).
Update: how to fix the untrusted user error… in your .hgrc add:
[trusted]
users=*
groups=*
Enable Color in Mac OS X Terminal
Posted by Stuart in Zend Framework on April 23, 2010
Want to colorize your ls output in Terminal? Stick this in your ~/.bashrc or ~/.bash_profile files:
export CLICOLOR=1
While you are at it add this alias to include invisible files in ls:
alias ls='ls -la'
Oh! One more useful one… to reload your .bash_profile without quitting and restarting the shell:
source ~/.bash_profile
The iTunes Window Extends Off Screen and I Can’t Resize It, Help!
Posted by Stuart in Zend Framework on April 22, 2010
So you thought you could click the little plus button at the window’s top left corner (the green one unless you use the alternate Mac color scheme) to resize and you discovered that that only opens a tiny control panel?
Here is the big secret… hold down the option key while clicking the button with the plus on it at top left. Done! I love easy.
Wrap many lines of text in list item tags using RegEx
Posted by Stuart in Zend Framework on April 16, 2010
So I have an email with a huge list of names. They are displayed one per line. I want to wrap them in list item tags so I can stick them in an unordered list. Here is how to do it fast and painlessly…
First, here is what I start with (just imagine 1000 names, rather than 3):
Bob Smith, Acme Corp, CEO Janet Johnson, Barton Inc, VP for Development and Shoe Sizes Cat Sims, Transmo Inc, VP of Conference Room Chair Height Adjustments
Here is the regex I will find and replace with:
Find:
(.*)\r
Replace (pretend that last “\r” is right next to the list item closing tag:
The find code looks for anything with a carriage return at the end and then grabs the bit in the parenthesis.
The replace code wraps that bit in the parenthesis (signified by the \1), wraps it in list item tags and sticks a carriage return on the end.
Now my list looks like:
Basic secure file copying using SCP
Posted by Stuart in Zend Framework on April 15, 2010
Securely copy a file from one computer to another (in this example on my local network):
$ sudo scp stuart@192.168.1.100:Downloads/somefile.iso /home/stuart/downloads
This will copy the file somefile.iso that is in my remote computer’s home dir’s Download directory ~/Downloads/ or put another way as the remote computer is a Mac /Users/stuart/Downloads/ over to the local computer’s dir at /home/stuart/downloads/





