| 1 | <?php |
| 2 | #phpinfo();die; |
| 3 | #print_r($_SERVER);die; |
| 4 | |
| 5 | |
| 6 | try { |
| 7 | |
| 8 | /** |
| 9 | * Read the configuration |
| 10 | */ |
| 11 | $config = include __DIR__ . "/../app/_config/config.php"; |
| 12 | |
| 13 | /** |
| 14 | * Read auto-loader |
| 15 | */ |
| 16 | include __DIR__ . "/../app/_config/loader.php"; |
| 17 | |
| 18 | /** |
| 19 | * Read services |
| 20 | */ |
| 21 | include __DIR__ . "/../app/_config/services.php"; |
| 22 | |
| 23 | /** |
| 24 | * Handle the request |
| 25 | */ |
| 26 | $application = new Phalcon\Mvc\Application($di); |
| 27 | |
| 28 | // Register the installed modules |
| 29 | $application->registerModules([ |
| 30 | 'frontend' => [ |
| 31 | 'className' => 'Multiple\Frontend\Module', |
| 32 | 'path' => '../app/frontend/Module.php' |
| 33 | ], |
| 34 | 'backend' => [ |
| 35 | 'className' => 'Multiple\Backend\Module', |
| 36 | 'path' => '../app/backend/Module.php' |
| 37 | ] |
| 38 | ]); |
| 39 | |
| 40 | $response = $application->handle( $_SERVER["REQUEST_URI"] ); |
| 41 | |
| 42 | // Get content and minify it |
| 43 | $content = $response->getContent(); |
| 44 | #$minifiedContent = minifier($content); |
| 45 | |
| 46 | // Set the minified content back to the response object |
| 47 | #$response->setContent($content); |
| 48 | |
| 49 | // Send the response to the client |
| 50 | $response->send(); |
| 51 | |
| 52 | } catch ( \Phalcon\Support\Debug\Exception $e) { |
| 53 | |
| 54 | |
| 55 | $message = get_class($e). ": ".$e->getMessage(). "\n" |
| 56 | . " File=". $e->getFile(). "\n" |
| 57 | . " Line=". $e->getLine(). "\n" |
| 58 | . $e->getTraceAsString() . "\n"; |
| 59 | |
| 60 | /* $logger = new \Phalcon\Logger\Adapter\File($config->application->logDir.'error.log'); |
| 61 | $logger->error($message);*/ |
| 62 | |
| 63 | echo $message; |
| 64 | |
| 65 | ########################## |
| 66 | ##### Debug deaktivieren on live: |
| 67 | #$debug = new \Phalcon\Debug(); |
| 68 | #die($debug->listen()->onUncaughtException($e)); |
| 69 | |
| 70 | } |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | function minifier($code) { |
| 76 | $search = array( |
| 77 | |
| 78 | // Remove whitespaces after tags |
| 79 | '/\>[^\S ]+/s', |
| 80 | |
| 81 | // Remove whitespaces before tags |
| 82 | '/[^\S ]+\</s', |
| 83 | |
| 84 | // Remove multiple whitespace sequences |
| 85 | '/(\s)+/s', |
| 86 | |
| 87 | // Removes comments |
| 88 | '/<!--(.|\s)*?-->/' |
| 89 | ); |
| 90 | $replace = array('>', '<', '\\1'); |
| 91 | $code = preg_replace($search, $replace, $code); |
| 92 | return $code; |
| 93 | } |