|
Saturday, June 13, 2009
PHP Again
Since my last post about PHP dev, Eclipse PDT seems to have matured a bit. So I am having a go at installing it. First, I uninstalled PHPEclipse and the xdebug plugins, and installed PDT. The instructions, mysteriously, are quite complex. Find them here. I had a very frustrating time getting dependencies to resolve properly, until I found a hint somewhere that suggested that my Eclipse install was "messed up." So I downloaded a fresh Eclipse for J2EE and finally got PDT 2.0 installed. This came at the cost of all the gaziilion other plugins I had installed, like the Google App Engine support, Ruby and Python support and so on. Feh. I'll live. I disliked all the UI clutter introduced by the xdebug plugin so, contrary to Paul Scott's advice, I am giving zend debugger a whirl. It seems that PDT comes with the "client" end of the Zend debugger, so all we need is the server. These instructions purport to guide one through that. Make a phpinfo.php file containing only Follow the instructions in the readme that comes with the download. First, I copied ZendDebugger.so into /usr/local/lib. Then I made /etc/php.ini by copying the default found in the same directory. This is what I added:
I was also told to copy dummy.php into your Apache docroot, but I don't know why. I put mine in To confirm that it's installed, we use our phpinfo.php and search for "debugger". There will be a reference next to the copyright as well as an entire section of zend debugger-related info. We need the client end of the debugger which is not provided by Eclipse for licensing reasons. Get it here. (The referring page is here.) Hmmm. It seems you can get it from an Eclipse update site as well. Leopard comes without pear so we have to install it: cd /usr/local curl http://pear.php.net/go-pear > go-pear.php sudo php -q go-pear.php Note that the go-pear script is very fragile and pretty badly written. It is easily confused. Make sure you are in the directory you want it to install into ( Now, to install PHPUnit, all we need do is It turns out that PDT does not support running PHPUnit directly, so I created an "external" run configuration in Eclipse to make it happen. [how? Maybe I'll fill in the details some time. Not now. It's my blog and I will write what I like.] I can finally test-drive some code! Next, deploy it. Zend Framework likes to assume it's at the root of your docroot, so people typically create a virtual host to make that happen. I found that Zend Framework apps really want to see Zend on the include_path so we add it in php.ini. But first we put a copy of the framework in a central spot. I chose /usr/local. So the whole download lives in /usr/local/ZendFramework-1.8.1. We'll want a symlink to isolate us from version lockin, so inside /usr/local, I did asudo pear channel-discover pear.phpunit.de sudo pear install phpunit/PHPUnit Now my include_path looks like this:ln -s ZendFramework-1.8.1 ZendFramework Then, in things like the quickstart app, I just went into the library directory and didinclude_path=".:/usr/local/PEAR:/usr/local/ZendFramework/library" Finally, in the quickstart, I did the requisiteln -s /usr/local/ZendFramework/library/Zend as dictated in the quickstart readme, and the db was created. Still following the instructions in the quickstart readme, I created the virtual host. I put it into /etc/apache2/extra/httpd-vhosts.conf and uncommented the include in httpd.conf. I added the line in /etc/host but here's the thing: Add ::1 as well as 127.0.0.1 since, being a futurtistic Mac, it uses IPv6. Apache had trouble with permissions when my docroot was in my home directory, so my virtual host's docroot ended up being /Library/WebServer/ZendFrameworkQuickstart-20090430 If you have permissions issues (you will), look in the apache log and chmod everything in sight. Finally, the app worked! Next, I tried making an app from scratch using the zh.sh script that comes with the framework. It's a bit like the RoR script(s) and is used to generate a new app, a new controller, a new view, etc. I made a do-nothing app and voila! it worked!php scripts/load.sqlite.php --withdata Still, the virtual host stuff has to be set up or nothing else will work. That's very troubling, as I can't imagine many ISPs being open to that level of messing with their Apache instance. More on that particular nightmare another time.zf.sh create controller auth zf.sh create action login auth zf.sh create action logout auth --view-included=0
Saturday, October 11, 2008
PHP and FMP
Get Expand it and copy it into Copy Edit php.ini. Uncomment and modify include_path = ".:/usr/local/php/includes" I set up eclipse by copying the features and plugins after downloading from http://www.eclipse.org/pdt/downloads/ I couldn't get the update site to work (mysterious errors.) Finally, after messing with it for ages, I concluded that Eclipse PDT doesn't work with Ganymede. I now use PHPEclipse. For debugging, we need xdebug. Oopsie. Must install pear to get pecl to get xdebug. So, curl http://pear.php.net/go-pear > go-pear.php sudo php -q go-pear.php Let the script update php.ini. And don't forget to update PATH like the script told you to. Then it's sudo pecl install xdebug And do NOT do what it says (You should add "extension=xdebug.so" to php.ini") Instead, add this: [xdebug] zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so Then confirm that it's working by doing php -mxdebug will show up both under [PHP Modules] and [Zend Modules] Get phpUnit installed. See Sebastian Bergmann's site: http://www.phpunit.de/manual/3.4/en/installation.html sudo pear channel-discover pear.phpunit.de sudo pear install phpunit/PHPUnit |
Twitter UpdatesArchives |