Running code before app starts, the best way in Silex
<p>I am building the application, for server monitoring and monitoring data filtering. This app uses the legacy code of Zabbix monitoring tool frontend which has some config files that needs to be included and some classes to work with database.</p>

<p>There are 3 main things that I should do before start interacting with the database:</p>

<pre><code>DBstart();

$serviceFactory = new CApiServiceFactory();

API::setApiServiceFactory($serviceFactory);

CWebUser::login($_SERVER['PHP_AUTH_USER'], '');
</code></pre>

<p>How can I or should I integrate these steps while using Silex? </p>

<p>API class with static method calls are used all over the place.</p>