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


PHP Slim::getInstance方法代码示例

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


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

示例1: _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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: authenticate

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

示例8: 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

示例9: 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

示例10: __construct

 /**
  * Constructor
  *
  * Initialize things.
  *
  */
 function __construct()
 {
     if (null == self::$_appInstance) {
         self::$_appInstance = Slim::getInstance();
     }
     Doctrine_Core::loadModels(MODELS_PATH);
     DoctrineAdapter::getInstance();
 }
开发者ID:edupol,项目名称:examsystem,代码行数:14,代码来源:DoctrineBaseClass.php

示例11: addQuote

function addQuote()
{
    $request = Slim::getInstance()->request();
    $data = json_decode($request->getBody());
    $quoteCrud = new QuotesCrud();
    $results = $quoteCrud->post($data);
    echo json_encode($results, JSON_NUMERIC_CHECK);
}
开发者ID:nagyistoce,项目名称:pmangular-php,代码行数:8,代码来源:quotes.php

示例12: _update

function _update($db, $collection, $id)
{
    $document = json_decode(Slim::getInstance()->request()->getBody(), true);
    $data = mongoUpdate(MONGO_HOST, $db, $collection, $id, $document);
    header("Content-Type: application/json");
    echo json_encode($data);
    exit;
}
开发者ID:kxopa,项目名称:slim-php-mongo-rest,代码行数:8,代码来源:index.php

示例13: show_result

 function show_result($data, $template = 'home.html', $error_code = null)
 {
     $app = Slim::getInstance();
     if ($app->request()->isAjax()) {
         echo json_encode($data);
     } else {
         $app->render($template, $data, $error_code);
     }
 }
开发者ID:inscriptionweb,项目名称:lebonmail,代码行数:9,代码来源:TwigView.php

示例14: addScanResults

/**
* A function to add a class
*/
function addScanResults()
{
    $results = json_decode(Slim::getInstance()->request()->post('scanResults'), true);
    try {
        $db = getConnection();
        $select = "SELECT idVertex FROM Vertices WHERE X=:coordinateX and Y=:coordinateY";
        $coordinate = $results['Coordinates'];
        $stmt = $db->prepare($select);
        $stmt->bindParam("coordinateX", $coordinate[0]);
        $stmt->bindParam("coordinateY", $coordinate[1]);
        $stmt->execute();
        $vertexId = $stmt->fetchAll(PDO::FETCH_OBJ);
        if (empty($vertexId)) {
            $insertVertex = "INSERT INTO Vertices(X, Y) VALUE(:coordinateX, :coordinateY)";
            $stmt = $db->prepare($insertVertex);
            $stmt->bindParam("coordinateX", $coordinate[0]);
            $stmt->bindParam("coordinateY", $coordinate[1]);
            $stmt->execute();
            $vertexId = $db->lastInsertId();
        } else {
            $vertexId = $vertexId[0]->idVertex;
        }
        $insertDirection = "INSERT INTO DirectionTime(direction) VALUE(:direction)";
        $stmt = $db->prepare($insertDirection);
        $stmt->bindParam("direction", $results['Direction']);
        $stmt->execute();
        $directionId = $db->lastInsertId();
        foreach ($results['Tests'] as $test) {
            foreach ($test as $accesspoint) {
                $selectMac = "SELECT idMac FROM Mac WHERE macAddress=:address";
                $stmt = $db->prepare($selectMac);
                $stmt->bindParam("address", $accesspoint['AccessPoint']);
                $stmt->execute();
                $macId = $stmt->fetchAll(PDO::FETCH_OBJ);
                if (empty($macId)) {
                    $insertMac = "INSERT INTO Mac(macAddress) VALUE(:address)";
                    $stmt = $db->prepare($insertMac);
                    $stmt->bindParam("address", $accesspoint['AccessPoint']);
                    $stmt->execute();
                    $macId = $db->lastInsertId();
                } else {
                    $macId = $macId[0]->idMac;
                }
                $finalInsert = "INSERT INTO Data(idVertex, idMac, idDirectionTime, strength) VALUE(:vertex, :mac, :direction, :strength)";
                $stmt = $db->prepare($finalInsert);
                $stmt->bindParam("vertex", $vertexId);
                $stmt->bindParam("mac", $macId);
                $stmt->bindParam("direction", $directionId);
                $stmt->bindParam("strength", $accesspoint['SignalStrength']);
                $stmt->execute();
            }
        }
        $db = null;
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
开发者ID:realjk,项目名称:IndoorLocalizationApp,代码行数:60,代码来源:index.php

示例15: __construct

 /**
  * Constructor
  *
  * Initialize things.
  *
  */
 function __construct()
 {
     if (null == self::$_appInstance) {
         self::$_appInstance = Slim::getInstance();
     }
     if (null == self::$_dbInstance) {
         self::$_dbInstance = PDOAdpter::getInstance();
     }
 }
开发者ID:edupol,项目名称:examsystem,代码行数:15,代码来源:BaseClass.php


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