Ok, to me this one is rather odd. But I'm probably just missing something.
I have a REST API using Slim with about 20 routes. Each route loads a MySQL class with a db config passed to the construct.
But, any time I'm adding a new route with a new db connection config (that I havent yet setup in the db), it throws a "bad db config" exception even though I am not calling the new/unfinished route.
So, it seems that the MySQL class in EVERY ROUTE is being instantiated whenever I make an API call.
Ummm..?
CODE SAMPLE PER REQUEST:
$app->group('/content/get', function () use ($app) {
require('config/mysql.settings.php');
$db = new MySQL($dbconfig['pages']);
$app->get('/:site/:page', function ($site, $page) use ($app, $db) {
...
});
});
$app->group('/library/get', function () use ($app) {
require('config/mysql.settings.php');
$db = new MySQL($dbconfig['docs']);
$app->get('/:doc', function ($doc) use ($app, $db) {
...
});
});
$app->group('/price/get', function () use ($app) {
require('config/mysql.settings.php');
$db = new MySQL($dbconfig['price']);
$app->get('/:doc', function ($doc) use ($app, $db) {
...
});
});
If the user for the "price" configuration hasnt been added to the db, and I make a call to /library/get, I get a db error. Once I add the price user to the db, the error stops.
It has done this with every new db user I specify in a route - until its actually added to the db.