Posts by Onno
Stuck in Certificate Hell on my MacBook Pro
0I’ve got some bitbucket repositories which I wanted to access with a MacBook Pro. To access my Git repositories I had to disable certificate checking to be able to clone them:
git config --global http.sslVerify false
I couldn’t find another proper way to do this. See HTTPS gibhub access – Stackoverflow
To clone mercurial repositories I had to add hostfingerprints configuration and a dummy cacerts certificate. See: Continue operation on failed certificate verification – Atlassian Answers
My .hgrc file:
[web] cacerts = /etc/hg-dummy-cert.pem [hostfingerprints] bitbucket.org = 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b
Redirect sub-sub-domains to dynamically configured virtual hosts on the localhost.
0A colleague (thanks Danny) pointed me to this solution to host multiple development environments under a single sub-domain name.
Step 1. Configure a type A domain record by using a wildcard and a fixed sub-domain name like:
*.lab A 127.0.0.1
( why didn’t I think of that x_X )
Step 2. Enable mod_vhost_alias in Apache if not already active.
Step 3. Configure a virtual host and use the wildcards from mod_vhost_alias to your liking, for example
<VirtualHost 127.0.0.1:80>
ServerName lab.yourdomain.com
VirtualDocumentRoot /var/my_flexible_friends/%1
</VirtualHost>
would redirect myproject.lab.yourdomain.com to 127.0.0.1 and serve pages from /var/my_flexible_friends/myproject but would also redirect jquery.lab.yourdomain.com to 127.0.0.1 and serve pages from /var/my_flexible_friends/jquery.
Just look at the mod_vhost_alias documentation for more possibilities.
Also a nice consistent setup to share in development teams.
If you happen to stumble upon apache error messages like ‘Request exceeded the limit of 10 internal redirects due to probable configuration error.’, just change your .htaccess file by added the rule RewriteBase /. This will most likely happen when you are using the windows hosts file instead of a real domain.
See also Stackoverflow Infinite Rewrite Loop
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteBase /
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
I guess PhpStorm does not love OpenJDK
0OpenJDK Runtime Environment (IcedTea6 1.9.10) (6b20-1.9.10-0ubuntu1~10.04.2)
OpenJDK Client VM (build 19.0-b09, mixed mode, sharing)
WARNING: You are launching IDE using OpenJDK Java runtimeTHIS IS STRICTLY UNSUPPORTED DUE TO KNOWN PERFORMANCE AND GRAPHICS PROBLEMS
NOTE: If you have both Sun JDK and OpenJDK installed
please validate either WEBIDE_JDK or JDK_HOME environment variable points to valid Sun JDK installation
Ubuntu Sun (Oracle) Java Installation Guide
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" sudo apt-get update aptitude install sun-java6-jdk sudo update-alternatives --config java
Disable Apache 404 ErrorDocument HTML
0While implementing a REST service, Apache started to append HTML 404 error HTML to my custom 404 application/json response.
It seems the Windows Apache version which comes with Zend Server requires a httpd.conf entry to disable the HTML to be appended to the response:
To disable it for a 404 error:
ErrorDocument 404 ” ”
So in general:
ErrorDocument
It’s weird though that the Linux version does not append this HTML error code by default.
PHPDoc an Array Param (in Zend Framework)
1I found this code snippet which shows how array based parameters should be documented with PHPDoc (in ZF projects). The topic came up because I’m always nagging about those magic functions and magic properties in ZF and how poorly they are documented. It seems we’ve been neglecting adding PHPDoc tags a bit because PHPDoc does have support to document magic methods and magic class properties:
/** * $args may contain the following keys: * - var1: * - var2: * * @param array @args * @return void */
Items prefixed with a ‘- ‘ will be treated as bullets by phpDocumentor.
source: zend framework community
I’m currently piloting PhpStorm because I had some issues with Zend Studio, it’s interesting to notice that a phpdoc line like:
/*
* @return Foo[]
*/
function getList() {
$f = array();
$f[] = new Foo();
...
return $f;
}
triggers auto-completion in PhpStorm when looping over the return value like:
$list = $this->getList();
foreach($list as $l) {
$l->(starts auto-completion ...)
}
Zend Tool Cheat Sheet (v1.11.10)
1Usage:
zf [--global-opts] action-name [--action-opts] provider-name [--provider-opts] [provider parameters ...]
Note: You may use “?” in any place of the above usage string to ask for more specific help information.
Example: “zf ? version” will list all available actions for the version provider.Providers and their actions:
| Version zf show version mode[=mini] name-included[=1] Note: There are specialties, use zf show version.? to get specific help on them.Config zf create config zf show config zf enable config Note: There are specialties, use zf enable config.? to get specific help on them. zf disable config Note: There are specialties, use zf disable config.? to get specific help on them. Phpinfo Manifest Profile Project Application Model |
View Controller Action Module Form Layout DbAdapter DbTable ProjectProvider |
Examples (Windows): zf create project ./ zf create module test zf create controller Test index-action-included=1 test
Remarks:
- The Zend Tool will maintain a xml based configuration file called ‘.zfproject.xml’, do not remove!
- Zend Tool is case sensitive, thus “zf create module blog” and “zf create module Blog” are different commands, running them both will create 2 modules (in Windows it will only result in 1 module directory though!)
- The create module command did not create a module Bootstrap file
- The bootstrap file in the tests directory has a lowercase ‘b’ which probably needs to be an uppercase like ‘Bootstrap.php’
- Note: PHPUnit is required in order to generate controller test stubs.
- For a module Bootstrap to work, the application.ini needs resources.modules = ""
A simple module Bootstrap looks like:
<?php
class Yourmodulename_Bootstrap extends Zend_Application_Module_Bootstrap {
protected function _initSomething () {
}
}
