weaverryan/PHP-Camp — pull request #1 by harikt (2014-10-31 05:10:51+00:00)
Title: Move the global functions to a closure 

Hi Ryan Weaver,

Nice work on the Kumbaya framework. I would like a few changes, which can bring much more better things than global functions, and slowly moving the views from the controller.

The idea is to follow "refactoring to architectural change" : https://github.com/auraphp/Aura.Dispatcher#refactoring-to-architecture-changes . I don't know if there is some better component out there to do with other than aura.

Somethings I don't know are

1. How to make a lazy object via pimple.

Eg :

```php
class AttendeesController
{
protected $pdo;

protected $request;

public function function(Request $request, PDO $pdo)
{
$this->pdo = $pdo;
$this->request = $request;
}

public function __invoke()
{
$sql = 'SELECT * FROM php_camp';
$content = '';
$content .= '

PHP Camp Attendees

';
$content .= '

';
foreach ($pdo->query($sql) as $row) {
$content .= sprintf(
'
%s
',
$row['attendee'],
$row['avatar_url']
);
}
$content .= '

';

return new Response($content);
}
}
```

```php
$dispatcher->setObject('attendees_controller', $c['AttendeesController']);
```

I don't need to instantiate the object of `AttendeesController` when setting the object. Is there a way in Pimple ?

In that case I would like to move all the closures to a class and may a folder `controllers`.

What do you think?

Thank you.