-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
74 lines (62 loc) · 1.83 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
try {
//Register an autoloader
$loader = new \Phalcon\Loader();
$loader->registerDirs(
array(
'./app/controllers/',
'./app/models/',
'./app/views/'
)
)->register();
$loader->registerClasses(
array(
"PHPMailer" => "app/ext/PHPMailer/PHPMailer.php",
)
)->register();
//Create a DI
$di = new Phalcon\DI\FactoryDefault();
//Setting up the view component
$di->set('view', function(){
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('./app/views/');
return $view;
});
$di->set('url', function() {
$url = new \Phalcon\Mvc\Url();
$url->setBaseUri('http:https://localhost/resetpwd/');
return $url;
});
/**
* Load router from external file
*/
$di->set('router', function(){
require __DIR__.'/app/config/routes.php';
return $router;
});
/**
* Start the session the first time some component request the session service
*/
$di->set('session', function(){
$session = new Phalcon\Session\Adapter\Files();
$session->start();
return $session;
});
/**
* Database connection is created based in the parameters defined in the configuration file
*/
$di->set('db', function(){
return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
"host" => 'localhost',
"username" => 'root',
"password" => '',
"dbname" => 'resetpwd',
));
});
//Handle the request
$application = new \Phalcon\Mvc\Application();
$application->setDI($di);
echo $application->handle()->getContent();
} catch(\Phalcon\Exception $e) {
echo "PhalconException: ", $e->getMessage();
}