Phalcon Framework 5.6.2

Phalcon\Mvc\Dispatcher\Exception: Web\Controllers\LaptopsController handler class cannot be loaded

/home/sahara/apps/inmlhiiiinjl/public/index.php (539)
#0Phalcon\Mvc\Dispatcher->throwDispatchException
#1Phalcon\Dispatcher\AbstractDispatcher->dispatch
#2Phalcon\Mvc\Application->handle
/home/sahara/apps/inmlhiiiinjl/public/index.php (539)
  1. <?php
  2.  
  3. //echo phpinfo(); exit;
  4. ini_set('display_errors', '1');
  5. ini_set('display_startup_errors', '1');
  6. error_reporting(E_ALL);
  7. use Phalcon\Mvc\Router,
  8. Phalcon\Mvc\Application,
  9. Phalcon\DI\FactoryDefault,
  10. Phalcon\Security,
  11. Phalcon\Loader;
  12. use Phalcon\Logger;
  13. use Phalcon\Logger\Adapter\File as FileAdapter;
  14. use Phalcon\Http\Cookie;
  15. use Phalcon\Http\Response\Cookies;
  16. use Phalcon\Logger\Adapter\Stream;
  17. use Phalcon\Html\Helper\Doctype;
  18. use Phalcon\Html\Escaper;
  19. $escaper = new Escaper();
  20. $helper = new Doctype($escaper);
  21. //(new \Phalcon\Debug)->listen();
  22. use Phalcon\Support\Debug;
  23. $debug = new Debug();
  24. $debug->listen();
  25.  
  26. define('BASE_PATH', dirname(__DIR__));
  27. define("BASE_URL", 'https://'. $_SERVER['HTTP_HOST']);
  28. define('APP_PATH', BASE_PATH . '');
  29. define('TEMPLATE', 'templates/');
  30.  
  31.  
  32. define('ROOT_PATH', dirname(__DIR__));
  33. $config = include APP_PATH . "/config/config.php";
  34.  
  35. //try {
  36.  
  37. /**
  38. * The FactoryDefault Dependency Injector automatically registers
  39. * the services that provide a full stack framework.
  40. */
  41.  
  42.  
  43. $di = new FactoryDefault();
  44.  
  45.  
  46.  
  47. $di->setShared('connection', function () use ($config) {
  48. return new \Phalcon\Db\Adapter\Pdo\Mysql([
  49. "host" => $config->database->host,
  50. "username" => $config->database->username,
  51. "password" => $config->database->password,
  52. "dbname" => $config->database->dbname,
  53. ]);
  54. });
  55.  
  56. require_once(APP_PATH . '/library/diFile.php');
  57. //Specify routes for modules
  58. $di->set('router', function () {
  59.  
  60. $router = new Router();
  61.  
  62. $module = 'www';
  63.  
  64.  
  65. $router->setDefaultModule($module);
  66.  
  67. $router->add(
  68. "/",
  69. array(
  70. "module" => $module,
  71. "controller" => 'index',
  72. "action" => 'index',
  73. ));
  74.  
  75. $router->add(
  76. "/:controller",
  77. array(
  78. "module" => $module,
  79. "controller" => 1,
  80. "action" => 'index'
  81. ));
  82. $router->add(
  83. "/:controller/",
  84. array(
  85. "module" => $module,
  86. "controller" => 1,
  87. "action" => 'index'
  88. ));
  89.  
  90. $router->add(
  91. "/:controller/:action",
  92. array(
  93. "module" => $module,
  94. "controller" => 1,
  95. "action" => 2
  96. ));
  97.  
  98. $router->add('/:controller/:action/',
  99. array(
  100. "module" => $module,
  101. "controller"=>1,
  102. "action"=>2,
  103. "params"=>3
  104. )
  105. );
  106. $router->add('/:controller/:action/:params',
  107. array(
  108. "module" => $module,
  109. "controller"=>1,
  110. "action"=>2,
  111. "params"=>3
  112. )
  113. );
  114.  
  115.  
  116. //sahara module
  117. //slab module
  118. $sahara = 'sahara';
  119. $router->add(
  120. "/".$sahara,
  121. array(
  122. "module" => 'sahara',
  123. "controller" => 'index',
  124. "action" => 'index',
  125. ));
  126.  
  127. $router->add(
  128. "/".$sahara."/",
  129. array(
  130. "module" => 'sahara',
  131. "controller" => 'index',
  132. "action" => 'index',
  133. ));
  134.  
  135. $router->add(
  136. "/".$sahara."/:controller",
  137. array(
  138. "module" => 'sahara',
  139. "controller" => 1,
  140. "action" => 'index'
  141. ));
  142. $router->add(
  143. "/".$sahara."/:controller/",
  144. array(
  145. "module" => 'sahara',
  146. "controller" => 1,
  147. "action" => 'index'
  148. ));
  149.  
  150. $router->add(
  151. "/".$sahara."/:controller/:action",
  152. array(
  153. "module" => 'sahara',
  154. "controller" => 1,
  155. "action" => 2
  156. ));
  157.  
  158. $router->add("/".$sahara."/:controller/:action/",
  159. array(
  160. "module" => 'sahara',
  161. "controller"=>1,
  162. "action"=>2,
  163. "params"=>3
  164. )
  165. );
  166. $router->add("/".$sahara."/:controller/:action/:params",
  167. array(
  168. "module" => 'sahara',
  169. "controller"=>1,
  170. "action"=>2,
  171. "params"=>3
  172. )
  173. );
  174.  
  175.  
  176. // $slabmodules = ['inventory','shop','sales','leasing','support','tenders','marketing','website','customers'];
  177.  
  178. // foreach ($slabmodules as $key => $value) {
  179. // $_controller = 'main';
  180. // $router->add(
  181. // "/".$slab."/".$value,
  182. // array(
  183. // "module" => 'slab',
  184. // "controller" => $_controller,
  185. // "action" => 'index',
  186. // "SLAB_MODULE" => $value
  187. // ));
  188. // $router->add(
  189. // "/".$slab."/".$value."/",
  190. // array(
  191. // "module" => 'slab',
  192. // "controller" => $_controller,
  193. // "action" => 'index',
  194. // "SLAB_MODULE" => $value
  195. // ));
  196.  
  197. // $router->add(
  198. // "/".$slab."/".$value."/:action",
  199. // array(
  200. // "module" => 'slab',
  201. // "controller" => $_controller,
  202. // "action" => 2,
  203. // "SLAB_MODULE" => $value
  204. // ));
  205.  
  206. // $router->add("/".$slab."/".$value."/:action/",
  207. // array(
  208. // "module" => 'slab',
  209. // "controller"=>$_controller,
  210. // "action"=>2,
  211. // "SLAB_MODULE" => $value
  212. // )
  213. // );
  214. // $router->add("/".$slab."/".$value."/:action/:params",
  215. // array(
  216. // "module" => 'slab',
  217. // "controller"=>$_controller,
  218. // "action"=>2,
  219. // "params"=>3,
  220. // "SLAB_MODULE" => $value
  221. // )
  222. // );
  223. // }
  224.  
  225. //end slab module
  226.  
  227.  
  228. // products
  229.  
  230. $products[700911483] = 'copy-printer';
  231. $products[390036435] = 'consumables';
  232. $products[265834157] = 'etr-machines';
  233. $products[262031572] = 'paper-shredders';
  234. $products[507279378] = 'photocopiers';
  235. $products[448243161] = 'printers';
  236. $products[545222025] = 'telephone-systems';
  237. $products[654456067] = 'laptops';
  238. $products[535686558] = 'desktops';
  239. $products[240813391] = 'networking';
  240. $products[319541512] = 'cameras-and-photography';
  241. $products[867537469] = 'electronics';
  242. $products[525003363] = 'electronics';
  243. $products[161610912] = 'phones-and-tablets';
  244. $products[723174557] = 'money-counter';
  245. $products[828362971] = 'shredders';
  246. $products[844223768] = 'binders';
  247. $products[226844082] = 'projectors';
  248.  
  249. foreach ($products as $key => $value) {
  250. $router->add(
  251. "/".$value,
  252. array(
  253. "module" => $module,
  254. "controller" => 'products',
  255. "action" => 'index',
  256. "product" => $value,
  257. "categoryId" => $key
  258. ));
  259. $router->add(
  260. "/".$value."/",
  261. array(
  262. "module" => $module,
  263. "controller" => 'products',
  264. "action" => 'index',
  265. "product" => $value,
  266. "categoryId" => $key
  267. ));
  268.  
  269. // $router->add(
  270. // "/".$value."/:action",
  271. // array(
  272. // "module" => $module,
  273. // "controller" => 'products',
  274. // "action" => 'filter',
  275. // "product" => $value,
  276. // "categoryId" => $key
  277. // ));
  278.  
  279. // $router->add("/".$value."/:action/",
  280. // array(
  281. // "module" => $module,
  282. // "controller"=> 'products',
  283. // "action"=> 'filter',
  284. // "product" => $value
  285. // )
  286. // );
  287. // $router->add("/".$value."/:action/:params",
  288. // array(
  289. // "module" => $module,
  290. // "controller"=>'products',
  291. // "action"=> 'filter',
  292. // "params"=>2,
  293. // "product" => $value
  294. // )
  295. // );
  296. }
  297.  
  298. //end products
  299.  
  300.  
  301.  
  302. // product
  303.  
  304. $productlist = array();
  305. $productlist[939038626] = 'photocopiers/ECOSYS-M3145idn';
  306. foreach ($productlist as $key => $value) {
  307.  
  308.  
  309. $router->add(
  310. "/".$value,
  311. array(
  312. "module" => $module,
  313. "controller" => 'product',
  314. "action" => 'index',
  315. "productId" => $key
  316. ));
  317.  
  318. $router->add(
  319. "/".$value."/",
  320. array(
  321. "module" => $module,
  322. "controller" => 'product',
  323. "action" => 'index',
  324. "productId" => $key
  325. ));
  326.  
  327.  
  328. }
  329.  
  330. //end product
  331.  
  332.  
  333.  
  334.  
  335. //images
  336. $images = array();
  337. $images[APP_PATH.'/frontend/image/'] = 'saharabg.png';
  338.  
  339.  
  340. foreach ($images as $key => $value) {
  341. $router->add(
  342. "/".$value,
  343. array(
  344. "module" => $module,
  345. "controller" => 'image',
  346. "action" => 'index',
  347. "path" => $key,
  348. "name" => $value,
  349. ));
  350. $router->add(
  351. "/".$value."/",
  352. array(
  353. "module" => $module,
  354. "controller" => 'image',
  355. "action" => 'index',
  356. "path" => $key,
  357. "name" => $value,
  358. ));
  359.  
  360. $router->add(
  361. "/".$value."/{token}",
  362. array(
  363. "module" => $module,
  364. "controller" => 'image',
  365. "action" => 'index',
  366. "path" => $key,
  367. "name" => $value,
  368. "token" => 1,
  369. ));
  370. }
  371. //end images
  372.  
  373.  
  374. return $router;
  375. });
  376.  
  377.  
  378. $di->setShared('session', function() {
  379.  
  380. // $session = new \Phalcon\Session\Adapter\Stream();
  381. // $session->start();
  382. // return $session;
  383.  
  384. $session = new Phalcon\Session\Manager();
  385. $files = new Phalcon\Session\Adapter\Stream( [
  386. 'savePath' => '/tmp',
  387. ]);
  388. $session->setAdapter($files)->start();
  389. return $session;
  390.  
  391. });
  392.  
  393. // $di->setShared('random', function() {
  394. // $random = new Phalcon\Security\Random();
  395. // return $random;
  396. // });
  397.  
  398. // $di->set('flash', function () {
  399. // $flash = new \Phalcon\Flash\Direct (
  400. // array(
  401. // 'error' => 'alert alert-danger',
  402. // 'success' => 'alert alert-success',
  403. // 'notice' => 'alert alert-info',
  404. // 'warning' => 'alert alert-warning'
  405. // )
  406. // );
  407.  
  408. // return $flash;
  409. // });
  410.  
  411. // $di->setShared('flashSession', function () {
  412. // $flash = new \Phalcon\Flash\Session (
  413. // // array(
  414. // // 'error' => 'alert alert-danger',
  415. // // 'success' => 'alert alert-success',
  416. // // 'notice' => 'alert alert-info',
  417. // // 'warning' => 'alert alert-warning'
  418. // // )
  419. // );
  420.  
  421. // return $flash;
  422. // });
  423.  
  424.  
  425. $di->set(
  426. "logger",
  427. function () {
  428. $logger = new FileAdapter("__DIR__ . '/../../logger.log");
  429.  
  430. return $logger;
  431. }
  432. );
  433.  
  434.  
  435. $di->setShared('controllerPath', function () {
  436. if (!empty($_SERVER['REQUEST_URI'])) {
  437. $uriParts = explode('?', $_SERVER['REQUEST_URI']);
  438. $segment = explode('/', $uriParts[0]);
  439. // $uri = str_replace('/', '', $uriParts[0]);
  440. $uri = $segment[1].'/';
  441. } else {
  442. $uri = '/';
  443. }
  444. return $uri;
  445. });
  446.  
  447. $di->set('users',function () {
  448.  
  449. include APP_PATH . '/services/users.php';
  450. return new Users();
  451. },
  452. true
  453. );
  454.  
  455. $di->set('categories',function () {
  456.  
  457. include APP_PATH . '/services/categories.php';
  458. return new Categories();
  459. },
  460. true
  461. );
  462.  
  463. $di->set('flash',function () {
  464.  
  465. include APP_PATH . '/services/flash.php';
  466. return new Flash();
  467. },
  468. true
  469. );
  470.  
  471. $di->set('directpay',function () {
  472.  
  473. include APP_PATH . '/services/directpay.php';
  474. return new Directpay();
  475. },
  476. true
  477. );
  478.  
  479. $di->set('item',function () {
  480.  
  481. include APP_PATH . '/services/item.php';
  482. return new Item();
  483. },
  484. true
  485. );
  486.  
  487. $di->set('redis',function () {
  488.  
  489.  
  490. include BASE_PATH . '/vendor/autoload.php';
  491.  
  492. include BASE_PATH . '/vendor/predis/Autoloader.php';
  493.  
  494. Predis\Autoloader::register();
  495.  
  496. /* $client = new Predis\Client();
  497. $client->set('foo', 'bar');
  498. $value = $client->get('foo');*/
  499.  
  500. $redis = new Predis\Client(array(
  501. "scheme" => "tcp",
  502. "host" => "127.0.0.1",
  503. "port" => 6379
  504. ));
  505.  
  506. return $redis;
  507.  
  508. });
  509. $application = new \Phalcon\Mvc\Application($di);
  510.  
  511. //Create an application
  512.  
  513. // Register the installed modules
  514. $application->registerModules(
  515. array(
  516. 'www' => array(
  517. 'className' => 'Web\Module',
  518. 'path' => APP_PATH.'/www/module.php',
  519. ),
  520. 'sahara' => array(
  521. 'className' => 'Sahara\Module',
  522. 'path' => APP_PATH.'/sahara/module.php',
  523. )
  524. )
  525. );
  526. $request = new \Phalcon\Http\Request();
  527. echo $application->handle($request->getURI())->getContent();
  528.  
  529. /*} catch (\Exception $e) {
  530. echo $e->getMessage() . '<br>';
  531. echo '<pre>' . $e->getTraceAsString() . '</pre>';
  532. }*/