0

index.php

//Initialise Slim
$composer = json_decode(file_get_contents(__DIR__.'/../composer.json');
$app = new \Slim\Slim(
 array(
  'verion'=>$composer->version,
  'debug'=>false,
  'mode'=>'production'
 )
);

I am learning how to add visualcaptcha to our login, but having trouble understanding what these lines mean.

This is how I would read it, get the content of composer.json and turn it into an array. So now the $composer has all the components that are needed for app app to work. Here is the tricky bit, I don't understand why is new \Slim\Slim(...)? Also I made an assumption that it is an relative path to the Slim Framework.

I read this link to understand more about composer and this link about slim framework. But still having trouble understanding this. Maybe I am used to javascript or java and having trouble with other alternatives implementations.

Thanks in advance

roger
  • 1,225
  • 2
  • 17
  • 33
  • 1
    http://docs.slimframework.com/configuration/overview/ – chiliNUT Oct 27 '16 at 23:32
  • Thanks chillNUT. So it is instantiating multiple settings, but it does not explain why it has `\' in front of Slim and two `Slim`? – roger Oct 27 '16 at 23:55
  • 1
    Fair enough, based on your question I couldn't tell that that is what you were asking about. It denotes `namespacing`, which you can read more about here: http://php.net/manual/en/language.namespaces.php – chiliNUT Oct 28 '16 at 00:57
  • No you were right from the beginning, your first link did explain the inner part of the code. Now I realise I was also asking about the `namespacing`. anyway I can read these two lines. Cheers, this is really helpful. – roger Oct 28 '16 at 01:41

0 Answers0