php slim 视频,php简单测试slim框架的功能

php简单测试slim框架的功能

监听主路径/

$app->get(

'/',

function () {

$template = <<

Slim Framework for PHP 5

QkAAAAAElFTkSuQmCC

Welcome to Slim!

Congratulations! Your Slim application is running. If this is

your first time using Slim, start with this "Hello World" Tutorial.

Get Started

The application code is in index.php

Follow @slimphp on Twitter

Slim Framework Community

Support Forum and Knowledge Base

Visit the Slim support forum and knowledge base

to read announcements, chat with fellow Slim users, ask questions, help others, or show off your cool

Slim Framework apps.

Twitter

Follow @slimphp on Twitter to receive the very latest news

and updates about the framework.

Slim Framework Extras

Custom View classes for Smarty, Twig, Mustache, and other template

frameworks are available online in a separate repository.

EOT;

echo $template;

}

);

测试接收路径

$app->get(

'/post',

function () {

echo 'This is a POST route';

}

);

输入http://localhost/lims/index.php/post路径

出现This is a POST route

测试display

$app->get('/bar', function (){

// echo $_SERVER['SCRIPT_NAME'];

// echo $_SERVER['PHP_SELF'];

// // $app->redirect($_SERVER['SCRIPT_NAME'].'/');

$view = new \Slim\View();

$prop1 = new \ReflectionProperty($view, 'data');

$prop1->setAccessible(true);

$prop1->setValue($view, new \Slim\Helper\Set(array('foo' => 'bar','ss'=>array('foo'=>'barsss'))));

$prop2 = new \ReflectionProperty($view, 'templatesDirectory');

$prop2->setAccessible(true);

$prop2->setValue($view, dirname(__FILE__) . '/tests/templates');

$view->display('test.php');

});

输入http://localhost/lims/index.php/bar

出现test output barsss

正常

测试redirect

$app->get('/bar', function (){

$app->redirect($_SERVER['SCRIPT_NAME'].'/');

});

出现主页面,正常,slim框架几百k,用起来还是不错的。

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值