December 2nd, 2009
It’s been awhile since I had to set up a new site with Zend Framework, and I took the chance to play around with Zend_Tool_Project. Following the QuickStart guide, I had a site up and running in no time. But it did take me a little while to figure out how to get my modules and custom library working with the site.
Modules
To get modules enabled, you first need to create a module with Zend_Tool_Project, or you can manually create a modules directory and add the module folder there. If I wanted to add a module called
cms, I would create application/modules/cms or use the command line
zf create module cms.
Then, In application.ini, you need to add the following two lines:
resources.modules[] =
resources.frontController.moduleDirectory = APPLICATION_PATH “/modules”
Finally, in order to load models and views, you need to add a Bootstrap.php file in the root of the modules - i.e. application/modules/cms/Bootstrap.php. In the module Bootstrap.php, place the following:
<?php
class Cms_Bootstrap extends Zend_Application_Module_Bootstrap
{
}
?>
You should be all set with modules now. Models you create within the module will use the naming convention of Cms_Model_Foo and controllers will be Cms_IndexController (when using Zend_Tool_Project and issuing zf create controller index index-action-included=1 cms, it names the controller class IndexController instead of Cms_IndexController?)
Autoloading Custom Library
The last thing I needed was to autoload my personal library which uses the naming convention Bolton_. My custom library resides in the same folder as the Zend library and is within my include path set in php.ini. In application.ini, you need to add the following line:
autoloaderNamespaces[] = \"Bolton_\"
Posted in Zend Framework | No Comments »
November 3rd, 2009
I had a site that uses Technorati’s API via Zend Framework- i.e. Zend_Service_Technorati. I noticed I am getting TCP connection errors via an exception (Message: Unable to Connect to tcp://api.technorati.com:80. Error #111: Connection refused), and upon going to Technorati’s site to look at the API, I found out the new API is under works and the old API is available until October 25th, 2009. It is November 3rd, the old API apparently doesn’t work and the new API isn’t released. Really? Am I missing something here? TCP connection failing tells me they are rejecting completely rejecting the TCP connection, which leads me to believe they have shut off the API. Searching on Twitter confirms this, although having an existing key doesn’t seem to matter…
Posted in Zend Framework | 2 Comments »
November 1st, 2009
<?php
$mapper->expects($this->exactly(‘2′))->method(‘delete’);
$mapper->expects($this->exactly(2))->method(‘delete’);
?>
The two above lines of code don’t behave the same. When passing in 2 as a string instead of a number, PHPUnit declares it a failure:
Em_Model_Collection_MapperTest::testDeleteCollectionWithJoinTable
Expectation failed for method name is equal to when invoked 2 time(s).
Method was expected to be called 2 times, actually called 2 times.
Posted in PHP | No Comments »
October 15th, 2009
I am new to MooTools and was using MooTools 1.2.3 to submit a form via Ajax - pretty standard stuff. When trying to put in callbacks for onSuccess,onRequest, etc… I kept getting JavaScript errors (b.lastIndexOf is not a function). Looks like you need to use set() function first, then call send(). MooTools must have been updated, because there are a lot of examples on the intraweb that do not do this, but work in my browser. To add to my confustion, you can call send() on the form without set first as long as you don’t pass an object with callbacks as a parameter in send().
This works
window.addEvent('domready', function() {
$('myForm').addEvent('submit',function(event) {
event.preventDefault();
this.send();
})
});
This does not work
window.addEvent('domready', function() {
$('myForm').addEvent('submit',function(event) {
event.preventDefault();
this.send({onComplete:function(){alert('this');}});
})
});
This works with callbacks
window.addEvent('domready', function() {
$('myForm').addEvent('submit',function(event) {
event.preventDefault();
this.set('send',{onComplete:function(){
alert('this');
}
}).send();
})
});
Anyways, after a day of playing with MooTools, I have say I am impressed. Not sure why, but I think this is my favorite framework. I can’t say I have much experience with JS frameworks, and my JavaScript is pretty bad these days, but I am impressed with MooTools so far.
Posted in Uncategorized, JavaScript | No Comments »
September 28th, 2009
Apparently you can’t use FTP for symlinks? It’s been so long since I have mucked around with FTP, that I didn’t realize you could not create symlinks. I have an old site I still maintain and had to move it to a new hosting provider and the new provider did not give SSH access (well at least without charging for it). PHP to the rescue:
<?php
symlink(‘../gallery’,‘gallery’);
?>
Use the symlink command in PHP. Obviously you need to have the proper permissions, and since PHP may be running as a different user, your mileage may very. But it worked for me…
Posted in PHP, Linux | 2 Comments »