Second question of the day in regards to Silex.

Suppose I have this piece of code:
Code PHP:
$app->get('/mails/', function() use($app) {
	   return $app['twig']->render('index.html', array(
			'object' => getObject(),

Where do I place the getObject function? Do I just leave it in the index.php file, or do I create a new file and just include the new php file?

Is it still possible to create own classes, as if you weren't using a framework, or is there another way to create a class (a service maybe?)?