当前位置: 首页>>代码示例>>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;未经允许,请勿转载。