Wednesday, May 21, 2008

postfix smtpd connection hangs with no banner

I ran into an issue the other day where my Postfix mail server would accept an SMTP connection, but then would just hang without ever sending the initial ESMTP welcome banner. I discovered that because of high mail traffic, I had reached the maximum number of smtpd connections, so the new connection was stuck waiting. Since the server load was fairly low, I just raised the smtpd incoming connection limit. You can do this one of two ways

First way: change the process limit just for smtpd in master.cf.
Note the 200 in the "maxproc" field (the default is 100)
smtp      inet  n       -       n       -       200       smtpd 

Second way: change default_process_limit in your main.cf file (the default is 100).
This will affect all postfix processes, so be careful about taxing your server.

default_process_limit=200


Tuesday, May 13, 2008

CakePHP vs FUSE MVC framework - PHP

Admittedly, I'm a bit biased on the topic since FUSE has been one of my development projects for quite a while, but recently I've been working with CakePHP quite a bit. I enjoy working with Cake, but can't help but think of certain things that FUSE does (in my opinion) a bit better. I've compiled a list of a few items where I think the FUSE MVC Framework has a bit of an advantage on CakePHP.

To be fair, I've also included a few things where FUSE falls short for the moment. Before I begin, I'd also like to add that I think Cake is a great framework, and I've certainly taken cues from my work with Cake to integrate new features into FUSE.

Where FUSE Wins

1. The Query Builder object

Fetching the last 10 active employees in CAKE:
// Controller
$where_conditions[] = 'Employee.active=1';

$this->data['Employees'] = $this->Employee->findAll(
$where_conditions,
null,
null,
null,
10 );

// View
<?php foreach( $this->data['Employees'] as $employee ) {?>
<div>
<?php e($employee['Employees']['first_name'] . ' ' . $employee['Employees']['last_name'] );?>
</div>
<?php } ?>

The same thing in FUSE:
//Controller
$options['limit'] = 10;
$options['where'] = 'employees.active=1';

$this->active_employees = $this->employee->fetch_all( $options );
//View

<{ITERATOR active_employees}>
<div><{first_name}> <{last_name}></div>
<{/ITERATOR}>

The query builder is simply an object that, believe it or not, allows you to build queries. Nearly every method in FUSE that fetches data from the database (including aggregate methods like count_all()) can take a query builder object as one of its $options parameters, and it will apply the customization in that object to the query being executed.
Above is an example of the shorthand syntax for customizing queries. For more complex customization, you can use the SQLQuery object directly, as discussed in the FUSE Wiki

2. FUSE has a real templating system

Iterating through employees in CakePHP
<table>
<?php
foreach( $this->data['Results'] as $result ) {
?>
<tr><td><?php e($result['Employees']['name']);?></td></tr>
<?php
}
?>
</table>

The same thing in FUSE:
<table>
<{ITERATOR employees}>
<tr><td><{name}></td></tr>
<{/ITERATOR}>
</table>

Cake's templating system is too reminiscent of inline PHP, and is sure to send your graphics guy running in the other direction. The FUSE templating system was designed to be extremely simple but incredibly robust, not to mention made to integrate as seamlessly into HTML as possible.

3. Helper methods are easier in FUSE

To generate a dropdown box of all users by first name in Cake:
//Controller
$this->set('users', $this->User->generateList(null, null, null,'{n}.User.id', '{n}.User.first_name'));
// View:
<?php echo $form->input('SomeModel.user_id', array('class'=>'txt', 'type' => 'select')); ?>

The same thing in FUSE:
<{HTML/FormHelper::Select_all( 'User', 'id', 'first_name' )}>


Other compelling reasons to use FUSE over Cake include:
  • FUSE's User authentication and management system is much more intuitive than Cake's ACL implementation.

  • FUSE is also capable of doing nested included tables when fetching data. For example, using the 'include' option to any fetch method, one can account for the scenario where model A is linked to model B, and model B is linked to model C, but you want to select data from A, B, and C. Currently, in CakePHP, you would have to write the query manually. FUSE allows you to do:

    $options['include'] = array( 'modelA', 'modelB', 'modelB.modelC' );
    $iterator = $this->fetch_all( $options );


Where CakePHP Wins

1. CakePHP has a larger user base

Although FUSE has been in development for several years, it was only released to the general public in January of 2008. As a result, its user base is still growing, and CakePHP is a more established framework with more documentation, forums, and third party code dedicated to it. The features of each framework are generally comparable, but the size of the CakePHP community is a huge advantage over FUSE.

2. CakePHP supports database other than mySQL

FUSE 1.1 only has a database object for mySQL, but MSSQL, PostgreSQL and SQLite classes are in the works. Additionally, FUSE will not support using data from multiple databases in one project until 1.1.1.

3. CakePHP has more direct AJAX integration

FUSE supports a variety of AJAX options and makes it very easy to use JQuery, but as of version 1.1, it is not as well integrated as some of Cake's AJAX functionality.

4. Your comment here

I know I'm going to get flamed for leaving the "Where Cake wins" section so short, so I figured I'd offer the opportunity for readers to add their own favorite things about CakePHP by commenting on this entry