phalcon——HTTP 请求

(一般在控制器方法中使用)

获取值:

(1)直接获取值:

$customerName = $this->request->getPost("name");

(2)自动添加过滤器:

$email = $this->request->getPost("user_email", "email");

(3)手动添加过滤器:

$filter = new Filter();

$email  = $filter->sanitize($this->request->getPost("user_email"), "email");

(4)若值为空,设置默认值

$email = $this->request->getPost("user_email", "email", "[email protected]");

使用请求头信息:

(1)获取服务器IP地址:

$ipAddress  =  $this->request->getServerAddress();

(2)获取客户端IP地址:

$ipAddress  =  $this->request->getClientAddress();

文件上传:

use Phalcon\Mvc\Controller;

class PostsController extends Controller

{

public function uploadAction()

{

// Check if the user has uploaded files

if ($this->request->hasFiles()) {

// Print the real file names and sizes

foreach ($this->request->getUploadedFiles() as $file) {

// Print file details

echo $file->getName(), " ", $file->getSize(), "\n";

// Move the file into the application

$file->moveTo(‘files/‘ . $file->getName());

}

}

}

}

时间: 2024-08-30 15:22:22

phalcon——HTTP 请求的相关文章

Phalcon之缓存对象关系映射(Caching in the ORM)

现实中的每个应用都不同,一些应用的模型数据经常改变而另一些模型的数据几乎不同.访问数据库在很多时候对我们应用的来说 是个瓶颈.这是由于我们每次访问应用时都会和数据库数据通信,和数据库进行通信的代价是很大的.因此在必要时我们可以通过增加 缓存层来获取更高的性能. 本章内容的重点即是探讨实施缓存来提高性能的可行性.Phalcon框架给我们提供了灵活的缓存技术来实现我们的应用缓存. 缓存结果集(Caching Resultsets)? 一个非常可行的方案是我们可以为那些不经常改变且经常访问的数据库数据

Phalcon之教程 2:INVO 项目讲解(Tutorial 2: Explaining INVO)

教程 2:INVO 项目讲解(Tutorial 2: Explaining INVO) In this second tutorial, we'll explain a more complete application in order to deepen the development with Phalcon. INVO is one of the applications we have created as samples. INVO is a small website that a

Phalcon Cookie管理

2.27 Cookies Management cooke管理 Cookies are very useful way to store small pieces of data in the client that can be retrieved even if the user closes his/her browser.Phalcon\Http\Response\Cookiesacts as a global bag for cookies. Cookies are stored in

谢烟客-----LNP之PHP C 扩展 (Phalcon)

Nginx的特性: 高性能的静态web服务器 作为smtp,httpd,tomcat,pop3等反向代理服务器 10000个并发,仅消耗1M内存 基于libevent库,支持event的epoll的边缘触发机制. 异步IO,内存映射 负载均衡.缓存 支持ssl,https,fastcgi协议 支持不停机升级,日志滚动,配置更新 安装方式: 编译安装 rpm安装(epel) 编译安装nginx的步骤: 开发环境: CentOS 6:  yum groupinstall "Development T

phalcon:数据库分库,读写分离,负载均衡 系统方法执行顺序

用命名空间区分不同的数据库实例,对应代码结构上是不同的目录区分,在同一目录下基类负责初始化连接.连接来自初始化时注入的多个db服务 隐规则: initialize()在每个请求期间只会调用一次 为每个 new 创建的实例执行初始化任务使用onConstruct() namespace Company\Models\Notification;   /** * Class BaseModel * * beforeSave()和afterFetch()成对使用,用于读写数据时自动转化数据. * 例如自

phalcon: eventManager事件管理(结合dispatcher调度控制器)制作简单的acl

制作简单的acl, dispatcher(专门用来加载或调度或跳转到相应的url地址即XXXcontroller的调度器或控制器,能够在controller执行前对controller进行停止跳转等),控制器提供了一堆可以被调用的方法,即:action.action是控制器中用于处理请求的方法.默认情况下,全部 控制器public的方法都会映射到action并且可以通过URL访问.action负责解释请求和创建响应. public/index.php $di['aclResource'] = f

Phalcon之 提高性能:下一步该做什么?(Increasing Performance: What’s next?)

要开发出高性能的应用程序需要考虑多方面的因素: 服务器, 客户端, 网络, 数据库, web服务器,静态资源等. 本章中我集中分析如何提升系统的性能及如何检测应用的瓶颈. 关于服务端(Profile on the Server)? 每种应用都有不同, 持久的性能分析对找出系统瓶颈是非常必要的. 性能分析可以让我们更直观的看出何处为性能瓶颈,何处不是. 性能分析在一个请求中和另一请求中可能表现不一,所以要做出足够的分析及权衡方可给出结论. 关于 XDebug(Profiling with XDeb

Phalcon 我们的动机(Our motivation)

There are many PHP frameworks nowadays, but none of them is like Phalcon (Really, trust us on this one). Almost all programmers prefer to use a framework. This is primarily because it provides a lot of functionality that is already tested and ready t

phalcon——调度控制器

将侦听者绑定到组件上: use Phalcon\Mvc\Dispatcher as MvcDispatcher, Phalcon\Events\Manager as EventsManager; $di->set('dispatcher', function () { // 创建一个事件管理 $eventsManager = new EventsManager(); // 为“dispatch”类型附上一个侦听者 $eventsManager->attach("dispatch&qu