当前位置: 首页>>代码示例>>PHP>>正文


PHP Slim类代码示例

本文整理汇总了PHP中Slim的典型用法代码示例。如果您正苦于以下问题:PHP Slim类的具体用法?PHP Slim怎么用?PHP Slim使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Slim类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login

 /**
  *
  * @param Slim $app
  * @return boolean
  */
 public function login($app)
 {
     if (!$app->request()->isPost()) {
         return false;
     }
     $this->setUsername($app->request()->params('username'));
     $this->setPassword($app->request()->params('password'));
     return $this->valid();
 }
开发者ID:stojg,项目名称:puny,代码行数:14,代码来源:User.php

示例2: call

 /**
  * Call
  * @param array $env
  * @return array[status, header, body]
  */
 public function call(&$env)
 {
     try {
         return $this->app->call($env);
     } catch (Exception $e) {
         $env['slim.log']->error($e);
         $response = new Slim_Http_Response($this->renderBody($env, $e), 500);
         return $response->finalize();
     }
 }
开发者ID:daerduoCarey,项目名称:oj,代码行数:15,代码来源:PrettyExceptions.php

示例3: getRouting

 private function getRouting()
 {
     /** anomymous functions are supported by php >= 5.3 
      **/
     /*$this->get('/admin(/:options)', function ($options='(not set)') {
     			echo 'Hello admin! This is a dummy siteaccess for admins only.';
     			echo '<br />';
     			echo 'Your option is: '.$options;
     		});*/
     /**
      * This gets tne navigation model and current page object
      */
     #phpinfo();
     $app = new Slim();
     $request = $app->request();
     // Deletes Get-Parms
     self::$URI = $app->request()->getResourceUri();
     /*show(self::$URI);
     		show($request);
     		show ($_SERVER['PATH_INFO']);
     		*/
     /**/
     /**
      * WALK all Single, get Param and make Routing 
      * **/
     $this->_Navigation = $this->_getNavigationModel();
     $this->page = $this->_Navigation->getCurrent();
     if ($app->request()->isAjax()) {
         $this->get($this->page->url, $this->getAjax($this->page));
     } else {
         $this->get($this->page->url, $this->getPage($this->page));
     }
     /*
     $this->get('/', function () {
     	show ('Hello world! This is the root node.');
     });
     
     $this->get('/me', function () {
     	echo 'Hello world! You know me?';
     });
     
     $this->get(self::$URI, function () {
     	echo 'Hello world! This is very generic!!!';
     });
     */
     // ToDos
     // redirection
     // hardcoded link?!
     // Logik vor modules?
     // JS-Linking
     // else: We should determine a 404-error for files like Google authorization files
 }
开发者ID:rs3d,项目名称:Slimplr,代码行数:52,代码来源:Slimpr.php

示例4: testReturnsDiagnosticsForErrorResponse

 /**
  * Test middleware returns diagnostic screen for error response
  */
 public function testReturnsDiagnosticsForErrorResponse()
 {
     Slim_Environment::mock(array('SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/foo'));
     $app = new Slim(array('log.enabled' => false));
     $app->get('/foo', function () {
         throw new Exception('Test Message', 100);
     });
     $mw = new Slim_Middleware_PrettyExceptions();
     $mw->setApplication($app);
     $mw->setNextMiddleware($app);
     $mw->call();
     $this->assertEquals(1, preg_match('@Slim Application Error@', $app->response()->body()));
     $this->assertEquals(500, $app->response()->status());
 }
开发者ID:sjakk,项目名称:betatext,代码行数:17,代码来源:PrettyExceptionsTest.php

示例5: updateIcon

function updateIcon()
{
    $request = Slim::getInstance()->request();
    $body = $request->getBody();
    $body = json_decode($body);
    unset($body->created_date);
    if (!empty($body->image)) {
        file_put_contents('./icon_images/' . $body->image->filename, base64_decode($body->image->base64));
        $body->image = $body->image->filename;
    } else {
        unset($body->image);
    }
    $id = $body->id;
    unset($body->image_url);
    if (isset($body->imagee)) {
        unset($body->imagee);
    }
    if (isset($body->id)) {
        unset($body->id);
    }
    $allinfo['save_data'] = $body;
    $coupon_details = edit(json_encode($allinfo), 'icon', $id);
    if (!empty($coupon_details)) {
        $result = '{"type":"success","message":"Changed Succesfully"}';
    } else {
        $result = '{"type":"error","message":"Not Changed"}';
    }
    echo $result;
}
开发者ID:krishnendubhattacharya,项目名称:mFoodGateApi,代码行数:29,代码来源:icon.php

示例6: authenticate

function authenticate()
{
    $app = Slim::getInstance();
    if (!App::user()) {
        $app->redirect("/connect/");
    }
}
开发者ID:ryanj,项目名称:The-Event-Day,代码行数:7,代码来源:index.php

示例7: CustomerAction

function CustomerAction()
{
    $request = Slim::getInstance()->request();
    $customer = json_decode($request->getBody());
    //echo '{"users": ' . json_encode($user) . '}';exit;
    $token = $customer->access_token;
    //echo '{"error":{"text":"'.$token.'"}}'; exit;
    if ($customer->access_token != "") {
        $status_token = validate_token($customer->access_token);
        //echo '{"error":{"text":"'.$status_token.'"}}'; exit;
        if ($status_token == 'valid') {
            $sql = "INSERT INTO user_profile (firstname, lastname) VALUES ('" . $customer->first_name . "', '" . $customer->last_name . "' )";
            $db_host = "127.0.0.1";
            $db_user = "root";
            $db_pass = "";
            $db_name = "myavazone_db";
            $db = new DB();
            $db->connect($db_host, $db_user, '', false, false, $db_name, 'tbl_');
            $res_q = $db->query($sql);
            echo '{"apidata": "User Added Sucessfully."}';
            exit;
            break;
            //echo '{"error":{"text":'.mc_encrypt($user->password,$user->key).'}}';
            //echo '{"error":{"text":"Token is valid"}}';
        } else {
            echo '{"error":{"text":"Token is not valid"}}';
        }
    } else {
        echo '{"error":{"text":"Token is NULL"}}';
    }
    /*$user_details=array(
    		'password_hash'	=>	mc_encrypt('admin@123','d0a7e7997b6d5fcd55f4b5c32611b87cd923e88837b63bf2941ef819dc8ca282')
    	);*/
}
开发者ID:vijay-panchal,项目名称:myAvazonic,代码行数:34,代码来源:customer_manager.php

示例8: updatePerson

function updatePerson($id)
{
    $request = Slim::getInstance()->request();
    $data = json_decode($request->getBody());
    $sql = "UPDATE people SET \n\t\t\t\temail=:email,\n\t\t\t\tfname=:fname,\n\t\t\t\tlname=:lname,\n\t\t\t\tclientId=:clientId,\n\t\t\t\tstatus=:status,\n\t\t\t\tphone=:phone,\n\t\t\t\tnotes=:notes\n\t\t\t\tWHERE id=:id";
    try {
        $db = getConnection();
        $stmt = $db->prepare($sql);
        $stmt->bindParam("email", $data->email);
        $stmt->bindParam("fname", $data->fname);
        $stmt->bindParam("lname", $data->lname);
        $stmt->bindParam("email", $data->email);
        $stmt->bindParam("email", $data->email);
        $stmt->bindParam("clientId", $data->clientId);
        $stmt->bindParam("status", $data->status);
        $stmt->bindParam("phone", $data->phone);
        $stmt->bindParam("notes", $data->notes);
        $stmt->bindParam("id", $id);
        $stmt->execute();
        $db = null;
        echo json_encode($data);
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
开发者ID:nagyistoce,项目名称:pmangular-php,代码行数:25,代码来源:people.php

示例9: save

 public function save()
 {
     GUMP::add_validator("unique", function ($field, $input, $param = NULL) {
         $checkExistingUser = R::findOne('user', 'user=?', array($input));
         if ($checkExistingUser == NULL) {
             return FALSE;
         } else {
             return TRUE;
         }
     });
     GUMP::add_validator("strong", function ($field, $input, $param = NULL) {
         return checkPasswordStrength($input);
     });
     $rules = array('reseller_username' => 'required|alpha_numeric|max_len,10|min_len,6|unique', 'reseller_password' => 'required|max_len,10|min_len,7|strong');
     $filters = array('reseller_username' => 'trim|sanitize_string', 'reseller_password' => 'trim|sanitize_string|md5');
     $app = Slim::getInstance();
     $post = $app->request()->post();
     // $app - Slim main app instance
     $postValues = $gump->filter($post, $filters);
     $validated = $gump->validate($gump->filter($postValues, $filters), $rules);
     if ($validated === TRUE) {
         $createUser = R::dispense('user');
         $createUser->user = $postValues['reseller_username'];
         $createUser->user = $postValues['reseller_password'];
     } else {
         $this->setError($gump->get_readable_errors(true));
     }
     if ($this->getError() == "") {
         $this->fails = FALSE;
     } else {
         $this->fails = TRUE;
     }
 }
开发者ID:bogiesoft,项目名称:Slim_PHP_Project,代码行数:33,代码来源:reseller_library.php

示例10: _update

function _update($collection, $id)
{
    $document = json_decode(Slim::getInstance()->request()->getBody(), true);
    $data = MongoDB::mongoUpdate(MONGO_HOST, MONGO_DB, $collection, $id, $document);
    $app->response()->header('Content-Type', 'application/json');
    echo json_encode($data);
}
开发者ID:kzima,项目名称:slimbone,代码行数:7,代码来源:api.php

示例11: testResponseContentTypeIsOverriddenToHtml

 /**
  * Test middleware overrides response content type to html
  */
 public function testResponseContentTypeIsOverriddenToHtml()
 {
     Slim_Environment::mock(array('SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/foo'));
     $app = new Slim(array('log.enabled' => false));
     $app->get('/foo', function () use($app) {
         $app->contentType('application/json;charset=utf-8');
         //<-- set content type to something else
         throw new Exception('Test Message', 100);
     });
     $mw = new Slim_Middleware_PrettyExceptions();
     $mw->setApplication($app);
     $mw->setNextMiddleware($app);
     $mw->call();
     $response = $app->response();
     $this->assertEquals('text/html', $response['Content-Type']);
 }
开发者ID:raynaldmo,项目名称:php-education,代码行数:19,代码来源:PrettyExceptionsTest.php

示例12: deleteFriendship

function deleteFriendship()
{
    global $friendTable, $userTable;
    /* verifica se existe alguma informacao no corpo da mensagem */
    $request = Slim::getInstance()->request();
    $json = readRequestBody($request);
    if (!$json) {
        $response["status"] = 0;
        echo json_encode($response);
        return;
    }
    /* lendo dados do json */
    $appID = $json->appID;
    $crypt_data = $json->data;
    $iv = $json->iv;
    $json = json_decode(decrypt_data($appID, $crypt_data, $iv));
    $id1 = $json->idusuario_a;
    $id2 = $json->idusuario_b;
    $response["status"] = 1;
    $dbh = getConnection();
    $sql = "DELETE FROM {$friendTable} where (idusuario_a = :id1 and\n\t\t\t\tidusuario_b = :id2) or (idusuario_a = :id2 and\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tidusuario_b = :id1)";
    $stmt = $dbh->prepare($sql);
    $stmt->bindParam(":id1", $id1);
    $stmt->bindParam(":id2", $id2);
    $stmt->execute();
    closeConnection($dbh);
    $json = json_encode($response);
    $data = encrypt_data($appID, $json);
    echo json_encode($data);
}
开发者ID:renvieir,项目名称:emprestae,代码行数:30,代码来源:friendship.php

示例13: youtube_oauth

function youtube_oauth()
{
    global $config;
    $app = Slim::getInstance();
    $code = $app->request()->get("code");
    if ($code) {
        //initial
        $access_params = array("code" => $code, "client_id" => $config["youtube_client_id"], "client_secret" => $config["youtube_client_secret"], "redirect_uri" => $config["youtube_oauth_callback"], "grant_type" => "authorization_code");
        $ch = curl_init("https://accounts.google.com/o/oauth2/token");
        curl_setopt($ch, CURLOPT_POST, count($access_params));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $access_params);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $json_string_data = curl_exec($ch);
        curl_close($ch);
        if ($json_string_data) {
            $auth_data = json_decode($json_string_data, true);
            $_SESSION["youtube_auth"] = $auth_data;
            dump($auth_data);
            //make a call to get the author data
            //log everything in the database
        } else {
            $app->redirect('/');
        }
    } else {
        $app->redirect('/');
    }
}
开发者ID:natestarner,项目名称:preachcaster,代码行数:27,代码来源:youtube_oauth.php

示例14: getLayout

 /**
  * Returns the layout for this view. This will be either
  * the 'layout' data value, the applications 'layout' configuration
  * value, or 'layout.php'.
  *
  * @param array $data Any additonal data to be passed to the template.
  *
  * @return string|null
  */
 public function getLayout($data = null)
 {
     $layout = null;
     // 1) Check the passed in data
     if (is_array($data) && array_key_exists(self::LAYOUT_KEY, $data)) {
         $layout = $data[self::LAYOUT_KEY];
         unset($data[self::LAYOUT_KEY]);
     }
     // 2) Check the data on the View
     if ($this->has(self::LAYOUT_KEY)) {
         $layout = $this->get(self::LAYOUT_KEY);
         $this->remove(self::LAYOUT_KEY);
     }
     // 3) Check the Slim configuration
     if (is_null($layout)) {
         $app = Slim::getInstance();
         if (isset($app)) {
             $layout = $app->config(self::LAYOUT_KEY);
         }
     }
     // 4) Use the default layout
     if (is_null($layout)) {
         $layout = self::DEFAULT_LAYOUT;
     }
     return $layout;
 }
开发者ID:superchangme,项目名称:jsplugin,代码行数:35,代码来源:LayoutView.php

示例15: call

 /**
  * Call
  * @param   array $env
  * @return  array[status, header, body]
  */
 public function call(&$env)
 {
     $env['slim.flash'] = $this;
     list($status, $header, $body) = $this->app->call($env);
     $this->save();
     return array($status, $header, $body);
 }
开发者ID:normanyung,项目名称:poggin,代码行数:12,代码来源:Flash.php


注:本文中的Slim类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。