當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Slim::request方法代碼示例

本文整理匯總了PHP中Slim::request方法的典型用法代碼示例。如果您正苦於以下問題:PHP Slim::request方法的具體用法?PHP Slim::request怎麽用?PHP Slim::request使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Slim的用法示例。


在下文中一共展示了Slim::request方法的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: 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

示例3: testDefaultInstanceProperties

 /**
  * Test default instance properties
  */
 public function testDefaultInstanceProperties()
 {
     $s = new Slim();
     $this->assertInstanceOf('Slim_Http_Request', $s->request());
     $this->assertInstanceOf('Slim_Http_Response', $s->response());
     $this->assertInstanceOf('Slim_Router', $s->router());
     $this->assertInstanceOf('Slim_View', $s->view());
     $this->assertInstanceOf('Slim_Log', $s->getLog());
     $this->assertEquals(Slim_Log::DEBUG, $s->getLog()->getLevel());
     $this->assertTrue($s->getLog()->getEnabled());
     $this->assertInstanceOf('Slim_Environment', $s->environment());
 }
開發者ID:raynaldmo,項目名稱:php-education,代碼行數:15,代碼來源:SlimTest.php

示例4: Slim

include_once './libs/Slim/Slim.php';
require_once './classes/dbHelper.php';
$app = new Slim();
$db = new dbHelper();
$app->get('/getperguntas/:idpalestra', function ($idpalestra) use($app) {
    global $db;
    $stmt = $db->selectperguntas("perguntaspalestras", "id,pergunta,nomeusuario", " idpalestra = '{$idpalestra}'");
    echo json_encode($stmt);
});
$app->post('/avaliarpalestra', function () use($app) {
    global $db;
    $idpalestra = "palestra01";
    $nota = 3;
    $email = "aaa@hotmail.com";
    $db->insert("avaliacao", array("idpalestra" => $idpalestra, "email" => $email, "nota" => $nota));
});
$app->post('/cadastrapergunta', function () use($app) {
    global $db;
    $postvalores = $app->request()->post();
    $idpalestra = $postvalores['idpalestra'];
    $pergunta = $postvalores['pergunta'];
    $nomeusuario = $postvalores['nomeusuario'];
    $db->insert("perguntaspalestras", array("idpalestra" => $idpalestra, "pergunta" => $pergunta, "nomeusuario" => $nomeusuario));
});
$app->get('/', function () use($app) {
    $app->render('home.php');
});
$app->get('/iframe', function () use($app) {
    $app->render('iframe.php');
});
$app->run();
開發者ID:CBSoft2016,項目名稱:Servidor_CBSoft2016,代碼行數:31,代碼來源:index.php

示例5: defaultNotFound

 /**
  * Default Not Found handler
  *
  * @return void
  */
 public static function defaultNotFound() {
     echo self::generateTemplateMarkup('404 Page Not Found', '<p>The page you are looking for could not be found. Check the address bar to ensure your URL is spelled correctly. If all else fails, you can visit our home page at the link below.</p><a href="' . Slim::request()->getRootUri() . '">Visit the Home Page</a>');
 }
開發者ID:ntdt,項目名稱:Slim,代碼行數:8,代碼來源:Slim.php

示例6: request

 /**
  * Slim's request object
  *
  * @return \Slim\Http\Request
  */
 protected function request()
 {
     return $this->app->request();
 }
開發者ID:andrearruda,項目名稱:Farol-Sign-UOL-Feed,代碼行數:9,代碼來源:SlimController.php

示例7: function

    $user->getFriends($id);
});
$app->get('/users/:id/score', function ($id) use($user) {
    $user->getScore($id);
});
$app->get('/users/:id/rewards', function ($id) use($user) {
    $user->getRewards($id);
});
$app->get('/users/search/:name', function ($name) use($user) {
    $user->getByName($name);
});
$app->delete('/users/:id', function ($id) use($user) {
    $user->delete($id);
});
$app->post('/users', function () use($user, $app) {
    $request = $app->request();
    $body = $request->getBody();
    $vo = json_decode($body);
    $user->insert($vo);
});
$app->put('/users/:id', function ($id) use($user, $app) {
    $request = $app->request();
    $body = $request->getBody();
    $vo = json_decode($body);
    $vo->facebook_user_id = $id;
    $user->update($vo);
});
$app->put('/users/:id/score', function ($id) use($user, $app) {
    $request = $app->request();
    $body = $request->getBody();
    $vo = json_decode($body);
開發者ID:ArmandBiteau,項目名稱:secondsense,代碼行數:31,代碼來源:index.php

示例8: function

Slim::put('/put', function () {
    echo '<p>Here are the details about your PUT request:</p>';
    print_r(Slim::request());
});
//Sample PUT route for PHP <5.3
/*
Slim::put('/put', 'put_example');
function put_example() {
	echo '<br/><br/>Here are the details about your PUT request:<br/><br/>';
	print_r(Slim::request());
}
*/
//Sample DELETE route for PHP >=5.3
Slim::delete('/delete', function () {
    echo '<p>Here are the details about your DELETE request:</p>';
    print_r(Slim::request());
});
//Sample DELETE route for PHP <5.3
/*
Slim::delete('/delete', 'delete_example');
function delete_example() {
	echo '<br/><br/>Here are the details about your DELETE request:<br/><br/>';
	print_r(Slim::request());
}
*/
/*** NAMED ROUTES *****/
Slim::get('/hello/:name', function ($name) {
    echo "<p>Hello, {$name}!</p>";
    echo "<p>This route using name \"Bob\" instead of \"{$name}\" would be: " . Slim::urlFor('hello', array('name' => 'Bob')) . '</p>';
})->name('hello')->conditions(array('name' => '\\w+'));
/*** RUN SLIM ***/
開發者ID:Jud,項目名稱:Slim,代碼行數:31,代碼來源:bootstrap.php

示例9: function

/* == *
 *
 * FILTERS
 *
 * ==============================================*/
$app->hook('test.filer', function ($argument) {
    return $argument;
});
// End FILTERS
/* == *
 *
 * ROUTES
 *
 * ==============================================*/
$app->map('/', function () use($app) {
    if ($app->request()->isPost() && sizeof($app->request()->post()) == 2) {
        // if valid login, set auth cookie and redirect
        $testp = sha1('uAX8+Tdv23/3YQ==');
        $post = (object) $app->request()->post();
        if (isset($post->username) && isset($post->password) && sha1($post->password) == $testp && $post->username == 'bppenne') {
            //$app->setEncryptedCookie('bppasscook', $post->password, 0);
            $app->setCookie('user_cook', $post->username, 0);
            $app->setCookie('pass_cook', $post->password, 0);
            $app->redirect('./review');
        } else {
            $app->redirect('.');
        }
    }
    $app->render('login.html');
})->via('GET', 'POST')->name('login');
$authUser = function ($role = 'member') use($app) {
開發者ID:nerdfiles,項目名稱:slim_bp,代碼行數:31,代碼來源:index.php

示例10: Slim

<?php

require 'Slim/Slim.php';
//With custom settings
$app = new Slim();
//Mailchimp help route
$app->get('/mailchimp', function () use($app) {
    $app->render('mailchimp.php');
});
//Mailchimp webhook
$app->post('/mailchimp', function () use($app) {
    require_once 'MCAPI.class.php';
    $emailField = $app->request()->get('email');
    $listId = $app->request()->get('listid');
    $apiKey = $app->request()->get('apikey');
    //Make sure we have required data.
    if (empty($emailField) || empty($listId) || empty($apiKey)) {
        $app->halt(500, 'Your hook is missing required GET parameters.');
    }
    $email = $app->request()->post($emailField);
    $forename = $app->request()->post($app->request()->get('forename'));
    $surname = $app->request()->post($app->request()->get('surname'));
    $rid = $app->request()->post('id');
    //Make sure we have required data.
    if (empty($email)) {
        $app->halt(500, 'Your hook is missing email address.');
    }
    //If double opt in parameter is present, subscribe with double opt-in.
    $doubleOptIn = false;
    if (!is_null($app->request()->get('doubleoptin'))) {
        $doubleOptIn = true;
開發者ID:mikelovely,項目名稱:webhooks,代碼行數:31,代碼來源:index.php

示例11: Autoloader

require "libs/Simplepie/autoloader.php";
//Autoload para as Classes do SimplePie, para leitura de RSS
require "libs/Slim/Slim.php";
//Micro-framework Slim, para gerenciamento de rotas e alguns Helpers
include "app/funcoes.php";
//Funções próprias, como CSS, Javascript e Meta
include "app/config.php";
//Configurações gerais do sistema, através de Constantes.
date_default_timezone_set('America/Sao_Paulo');
$autoloader = new Autoloader();
$app = new Slim();
$app->contentType('text/html; charset=utf-8');
$app->add(new Slim_Middleware_SessionCookie(array('secret' => '98897qwer65465qwe9r79qw9e354as68dh56k6lks6df8g', 'expires' => '60 minutes')));
$authenticate = function ($app) {
    return function () use($app) {
        if (!isset($_SESSION['dehbora']['user'])) {
            $_SESSION['dehbora']['urlRedirect'] = $app->request()->getPathInfo();
            $app->flash('error', 'Você precisa se logar.');
            $app->redirect(URL_BASE . '/inicial');
        }
    };
};
$app->hook('slim.before.dispatch', function () use($app) {
    $user = null;
    if (isset($_SESSION['dehbora']['user'])) {
        $user = $_SESSION['dehbora']['user'];
    }
    $app->view()->setData('user', $user);
});
require_once "app/routes.php";
$app->run();
開發者ID:romulo1984,項目名稱:dehbora,代碼行數:31,代碼來源:index.php

示例12: testSlimAccessors

 public function testSlimAccessors()
 {
     $app = new Slim();
     $this->assertTrue($app->request() instanceof Slim_Http_Request);
     $this->assertTrue($app->response() instanceof Slim_Http_Response);
     $this->assertTrue($app->router() instanceof Slim_Router);
 }
開發者ID:inscriptionweb,項目名稱:lebonmail,代碼行數:7,代碼來源:SlimTest.php

示例13: array

    }
    return $app->render('blog_detail.html', array('article' => $article));
});
// Admin Home.
$app->get('/admin', $authCheck, function () use($app) {
    $articles = Model::factory('Article')->order_by_desc('timestamp')->find_many();
    return $app->render('admin_home.html', array('articles' => $articles));
});
// Admin Add.
$app->get('/admin/add', $authCheck, function () use($app) {
    return $app->render('admin_input.html', array('action_name' => 'Add', 'action_url' => '/microframework/admin/add'));
});
// Admin Add - POST.
$app->post('/admin/add', $authCheck, function () use($app) {
    $article = Model::factory('Article')->create();
    $article->title = $app->request()->post('title');
    $article->author = $app->request()->post('author');
    $article->summary = $app->request()->post('summary');
    $article->content = $app->request()->post('content');
    $article->timestamp = date('Y-m-d H:i:s');
    $article->save();
    $app->redirect('/microframework/admin');
});
// Admin Edit.
$app->get('/admin/edit/(:id)', $authCheck, function ($id) use($app) {
    $article = Model::factory('Article')->find_one($id);
    if (!$article instanceof Article) {
        $app->notFound();
    }
    return $app->render('admin_input.html', array('action_name' => 'Edit', 'action_url' => '/microframework/admin/edit/' . $id, 'article' => $article));
});
開發者ID:rogeriopradoj,項目名稱:tuto-micro_slim,代碼行數:31,代碼來源:index.php

示例14: function

});
$app->map('/connect/', function () use($app) {
    $params = App::start();
    $params['title'] = "Connect";
    $params['page'] = "connect";
    $params['errors'] = array();
    # This user already has an active session
    if (App::user()) {
        $user = App::getUser();
        $params['user_email'] = $user->email;
        $params['user_name'] = $user->first_name . ' ' . $user->last_name;
        $params['button'] = "Logout";
    } else {
        # This user is not yet authenticated
        #  (it is their first visit, or they were redirected here after logout)
        if ($app->request()->get('code')) {
            # This user has just authenticated, get their access token and store it
            $connect = App::connect($app->request()->get('code'));
            if (array_key_exists('error', $connect)) {
                $params['errors'][] = $connect['error'];
            } else {
                if (array_key_exists('access_token', $connect)) {
                    App::begin($connect['access_token'], 1);
                    $user = App::getUser($connect['access_token']);
                    $params['user_email'] = $user->email;
                    $params['user_name'] = $user->first_name . ' ' . $user->last_name;
                    $params['button'] = "Logout";
                }
            }
        } else {
            if ($app->request()->get('error') == 'access_denied') {
開發者ID:ryanj,項目名稱:The-Event-Day,代碼行數:31,代碼來源:index.php

示例15: getUrl

 /**
  * Warpper function to get host URL.
  * From site.baseurl or auto detected by Slim.
  *
  * @return Host URL string
  */
 public function getUrl()
 {
     return $this->getConfig('site.baseurl') ? $this->getConfig('site.baseurl') : $this->slim->request()->getUrl();
 }
開發者ID:rogeriopradoj,項目名稱:TextPress,代碼行數:10,代碼來源:Textpress.php


注:本文中的Slim::request方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。