Example #1
0
        $cacheKey = $id;
        $product = $cache->get($cacheKey);
        $content = '已经添加过了!菜菜笨';
        if ($product === null) {
            $arr = ['id' => $id, 'file_path' => ''];
            $cache->save($cacheKey, json_encode($arr));
            $content = '添加成功!!菜菜好样的';
        }
    }
    $app->response->setContent($content);
    $app->response->send();
});
$app->notFound(function () use($app) {
    $app->response->setStatusCode(404, "Not Found")->sendHeaders();
    echo 'This is crazy, but this page was not found!';
});
$app->error(function (\Exception $e) {
    echo get_class($e), ": ", $e->getMessage(), "\n";
    echo " File=", $e->getFile(), "\n";
    echo " Line=", $e->getLine(), "\n";
    echo $e->getTraceAsString();
});
$app->handle();
//}
//catch (\Exception $e)
//{
//    echo get_class($e), ": ", $e->getMessage(), "\n";
//    echo " File=", $e->getFile(), "\n";
//    echo " Line=", $e->getLine(), "\n";
//    echo $e->getTraceAsString();
//}
Example #2
0
<?php

use Phalcon\Mvc\Micro;
use Phalcon\Http\Response;
require "config/config.php";
require "config/services.php";
$app = new Micro($di);
$app->get('/', function () use($app) {
    echo $app['view']->render('index');
});
$app->notFound(function () use($app) {
    echo $app['view']->render('404');
});
$app->error(function () use($app) {
    echo $app['view']->render('500');
});
$app->handle();