# 微应用(Micro Applications)[](# "永久链接至标题")
使用Phalcon框架开发者可以创建微框架应用。 这样开发者只需要书写极少的代码即可创建一个PHP应用。 微应用适用于书写小的应用, API或原型等
~~~
<?php
use Phalcon\Mvc\Micro;
$app = new Micro();
$app->get('/say/welcome/{name}', function ($name) {
echo "<h1>Welcome $name!</h1>";
});
$app->handle();
~~~
### 创建微应用(Creating a Micro Application)[](# "永久链接至标题")
Phalcon中 使用 [*Phalcon\Mvc\Micro*](#) 来实现微应用。
~~~
<?php
use Phalcon\Mvc\Micro;
$app = new Micro();
~~~
### 定义路由(Defining routes)[](# "永久链接至标题")
实例化后, 开发者需要添加一些路由规则。 Phalcon内部使用 [*Phalcon\Mvc\Router*](#) 来管理路由。 路由必须以 / 开头。定义路由时通常会书写http方法约束, 这样路由规则只适用于那些和规则及htttp方法相匹配的路由。 下面的方法展示了如何定义了HTTP get方法路由:
~~~
<?php
$app->get('/say/hello/{name}', function ($name) {
echo "<h1>Hello! $name</h1>";
});
~~~
get 方法指定了要匹配的请求方法。 路由规则 /say/hello/{name} 中含有一个参数 {$name}, 此参数会直接传递给路由的处理器(此处为匿名函数)。 路由规则匹配时处理器即会执行。处理器是PHP中任何可以被调用的项。 下面的示例中展示了如何定义不同种类的处理器:
~~~
<?php
// 函数
function say_hello($name) {
echo "<h1>Hello! $name</h1>";
}
$app->get('/say/hello/{name}', "say_hello");
// 静态方法
$app->get('/say/hello/{name}', "SomeClass::someSayMethod");
// 对象内的方法
$myController = new MyController();
$app->get('/say/hello/{name}', array($myController, "someAction"));
// 匿名函数
$app->get('/say/hello/{name}', function ($name) {
echo "<h1>Hello! $name</h1>";
});
~~~
[*Phalcon\Mvc\Micro*](#) 提供了一系列的用于定义http方法的限定方法:
~~~
<?php
// 匹配http get 方法:
$app->get('/api/products', "get_products");
// 匹配HTTP post方法
$app->post('/api/products/add', "add_product");
// 匹配http put 方法
$app->put('/api/products/update/{id}', "update_product");
// 匹配http delete方法
$app->delete('/api/products/remove/{id}', "delete_product");
// 匹配http options方法
$app->options('/api/products/info/{id}', "info_product");
// 匹配http patch方法
$app->patch('/api/products/update/{id}', "info_product");
// 匹配http get 或 post方法
$app->map('/repos/store/refs',"action_product")->via(array('GET', 'POST'));
~~~
To access the HTTP method data $app needs to be passed into the closure:
~~~
<?php
// Matches if the HTTP method is POST
$app->post('/api/products/add', function () use ($app) {
echo $app->request->getPost("productID");
});
~~~
### 路由参数(Routes with Parameters)[](# "永久链接至标题")
如上面的例子中展示的那样在路由中定义参数是非常容易的。 参数名需要放在花括号内。 参数格式亦可使用正则表达式以确保数据一致性。 例子如下:
~~~
<?php
// 此路由有两个参数每个参数有一格式
$app->get('/posts/{year:[0-9]+}/{title:[a-zA-Z\-]+}', function ($year, $title) {
echo "<h1>Title: $title</h1>";
echo "<h2>Year: $year</h2>";
});
~~~
### 起始路由(Starting Route)[](# "永久链接至标题")
通常情况下, 应用一般由 / 路径开始访问, 当然此访问多为 GET方法。 这种情况代码如下:
~~~
<?php
// 超始路由
$app->get('/', function () {
echo "<h1>Welcome!</h1>";
});
~~~
### 重写规则(Rewrite Rules)[](# "永久链接至标题")
下面的规则用来实现apache重写:
~~~
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
~~~
### 处理响应(Working with Responses)[](# "永久链接至标题")
开发者可以在路由处理器中设置任务种类的响应:直接输出, 使用模板引擎, 包含视图, 返回json数据等。
~~~
<?php
// 直接输出
$app->get('/say/hello', function () {
echo "<h1>Hello! $name</h1>";
});
// 包含其它文件
$app->get('/show/results', function () {
require 'views/results.php';
});
// 返回JSON
$app->get('/get/some-json', function () {
echo json_encode(array("some", "important", "data"));
});
~~~
另外开发者还可以使用 [*“response”*](#) , 这样开发者可以更好的处理结果:
~~~
<?php
$app->get('/show/data', function () use ($app) {
// 设置返回头部内容格式
$app->response->setContentType('text/plain')->sendHeaders();
// 输出文件内容
readfile("data.txt");
});
~~~
或回复response对象:
~~~
<?php
$app->get('/show/data', function () {
// 创建Response类实例
$response = new Phalcon\Http\Response();
// Set the Content-Type header 设置返回内容的类型
$response->setContentType('text/plain');
// 设置文件内容参数
$response->setContent(file_get_contents("data.txt"));
// 返回response实例对象
return $response;
});
~~~
### 重定向(Making redirections)[](# "永久链接至标题")
重定向用来在当前的处理中跳转到其它的处理流:
~~~
<?php
// 此路由重定向到其它的路由
$app->post('/old/welcome', function () use ($app) {
$app->response->redirect("new/welcome")->sendHeaders();
});
$app->post('/new/welcome', function () use ($app) {
echo 'This is the new Welcome';
});
~~~
### 根据路由生成 URL(Generating URLs for Routes)[](# "永久链接至标题")
Phalcon中使用 [*Phalcon\Mvc\Url*](#) 来生成其它的基于路由的URL。 开发者可以为路由设置名字, 通过这种方式 “url” 服务可以产生相关的路由:
~~~
<?php
// 设置名为 "show-post"的路由
$app->get('/blog/{year}/{title}', function ($year, $title) use ($app) {
// .. show the post here
})->setName('show-post');
// 产生url
$app->get('/', function () use ($app) {
echo '<a href="', $app->url->get(array(
'for' => 'show-post',
'title' => 'php-is-a-great-framework',
'year' => 2015
)), '">Show the post</a>';
});
~~~
### 与依赖注入的交互(Interacting with the Dependency Injector)[](# "永久链接至标题")
微应用中, [*Phalcon\DI\FactoryDefault*](#) 是隐含生成的, 不过开发者可以明确的生成此类的实例以用来管理相关的服务:
~~~
<?php
use Phalcon\Mvc\Micro;
use Phalcon\DI\FactoryDefault;
use Phalcon\Config\Adapter\Ini as IniConfig;
$di = new FactoryDefault();
$di->set('config', function () {
return new IniConfig("config.ini");
});
$app = new Micro();
$app->setDI($di);
$app->get('/', function () use ($app) {
// Read a setting from the config
echo $app->config->app_name;
});
$app->post('/contact', function () use ($app) {
$app->flash->success('Yes!, the contact was made!');
});
~~~
服务容器中可以使用数据类的语法来设置或取服务实例:
~~~
<?php
use Phalcon\Mvc\Micro;
use Phalcon\Db\Adapter\Pdo\Mysql as MysqlAdapter;
$app = new Micro();
// 设置数据库服务实例
$app['db'] = function () {
return new MysqlAdapter(array(
"host" => "localhost",
"username" => "root",
"password" => "secret",
"dbname" => "test_db"
));
};
$app->get('/blog', function () use ($app) {
$news = $app['db']->query('SELECT * FROM news');
foreach ($news as $new) {
echo $new->title;
}
});
~~~
### 处理Not-Found(Not-Found Handler)[](# "永久链接至标题")
当用户访问未定义的路由时, 微应用会试着执行 “Not-Found”处理器。 示例如下:
~~~
<?php
$app->notFound(function () use ($app) {
$app->response->setStatusCode(404, "Not Found")->sendHeaders();
echo 'This is crazy, but this page was not found!';
});
~~~
### 微应用中的模型(Models in Micro Applications)[](# "永久链接至标题")
Phalcon中开发者可以直接使用 [*Models*](#) , 开发者只需要一个类自动加载器来加载模型:
~~~
<?php
$loader = new \Phalcon\Loader();
$loader->registerDirs(array(
__DIR__ . '/models/'
))->register();
$app = new \Phalcon\Mvc\Micro();
$app->get('/products/find', function () {
foreach (Products::find() as $product) {
echo $product->name, '<br>';
}
});
$app->handle();
~~~
### 微应用中的事件(Micro Application Events)[](# "永久链接至标题")
当有事件发生时 [*Phalcon\Mvc\Micro*](#) 会发送事件到 [*EventsManager*](#) 。 这里使用 “micro” 来绑定处理事件。 支持如下事件:
| 事件名 | 如何触发 | 是否可中断执行 |
|-----|-----|-----|
| beforeHandleRoute | 处理方法调用之前执行, 此时应用程序还不知道是否存在匹配的路由 | 是 |
| beforeExecuteRoute | 存在匹配的路由及相关的处理器, 不过处理器还未被执行 | 是 |
| afterExecuteRoute | 处理器执行之后触发 | 否 |
| beforeNotFound | NotFound触发之前执行 | 是 |
| afterHandleRoute | 处理器执行之后执行 | 是 |
下面的例子中, 我们阐述了如何使用事件来控制应用的安全性:
~~~
<?php
use Phalcon\Mvc\Micro,
Phalcon\Events\Manager as EventsManager;
// 创建事件监听器
$eventManager = new EventsManager();
// 监听应用的所有事件
$eventManager->attach('micro', function ($event, $app) {
if ($event->getType() == 'beforeExecuteRoute') {
if ($app->session->get('auth') == false) {
$app->flashSession->error("The user isn't authenticated");
$app->response->redirect("/")->sendHeaders();
// 返回false来中止操作
return false;
}
}
});
$app = new Micro();
// 绑定事件管理器到应用
$app->setEventsManager($eventManager);
~~~
### 中间件事件(Middleware events)[](# "永久链接至标题")
此外, 应用事件亦可使用 ‘before', ‘after', ‘finish'等来绑定:
~~~
<?php
$app = new Phalcon\Mvc\Micro();
// 每个路由匹配之前执行
// 返回false来中止程序执行
$app->before(function () use ($app) {
if ($app['session']->get('auth') == false) {
return false;
}
return true;
});
$app->map('/api/robots', function () {
return array(
'status' => 'OK'
);
});
$app->after(function () use ($app) {
// 路由处理器执行后执行
echo json_encode($app->getReturnedValue());
});
$app->finish(function () use ($app) {
// 路由处理器执行后执行
});
~~~
开发者可以对同一事件注册多个处理器:
~~~
<?php
$app->finish(function () use ($app) {
// 第一个结束处理器
});
$app->finish(function () use ($app) {
// 第二个结束处理器
});
~~~
把这些代码放在另外的文件中以达到重用的目的:
~~~
<?php
use Phalcon\Mvc\Micro\MiddlewareInterface;
/**
* CacheMiddleware
*
* 使用缓存来提升性能
*/
class CacheMiddleware implements MiddlewareInterface
{
public function call($application)
{
$cache = $application['cache'];
$router = $application['router'];
$key = preg_replace('/^[a-zA-Z0-9]/', '', $router->getRewriteUri());
// 检查请示是否被处理了
if ($cache->exists($key)) {
echo $cache->get($key);
return false;
}
return true;
}
}
~~~
添加实例到应用:
~~~
<?php
$app->before(new CacheMiddleware());
~~~
支持如下的中间件事件:
| 事件名 | 触发 | 是否可中止操作? |
|-----|-----|-----|
| before | 应用请求处理之前执行,常用来控制应用的访问权限 | Yes |
| after | 请求处理后执行,可以用来准备回复内容 | No |
| finish | 发送回复内容后执行, 可以用来执行清理工作 | No |
### 使用控制器处理(Using Controllers as Handlers)[](# "永久链接至标题")
中型的应用可以使用 Micro\Mvc 来组织控制器中的处理器。 开发者也可以使用 [*Phalcon\Mvc\Micro\Collection*](#) 来对控制器中的处理器进行归组:
~~~
<?php
use Phalcon\Mvc\Micro\Collection as MicroCollection;
$posts = new MicroCollection();
// 设置主处理器,这里是控制器的实例
$posts->setHandler(new PostsController());
// 对所有路由设置前缀
$posts->setPrefix('/posts');
// 使用PostsController中的index action
$posts->get('/', 'index');
// 使用PostController中的show action
$posts->get('/show/{slug}', 'show');
$app->mount($posts);
~~~
PostsController形如下:
~~~
<?php
class PostsController extends Phalcon\Mvc\Controller
{
public function index()
{
// ...
}
public function show($slug)
{
// ...
}
}
~~~
上面的例子中,我们直接对控制器进行了实例化, 使用集合时Phalcon会提供了迟加载的能力, 这样程序只有在匹配路由时才加载控制器:
~~~
<?php
$posts->setHandler('PostsController', true);
$posts->setHandler('Blog\Controllers\PostsController', true);
~~~
### 返回响应(Returning Responses)[](# "永久链接至标题")
处理器可能会返回原生的 [*Phalcon\Http\Response*](#) 实例或实现了相关接口的组件。 当返回Response对象时, 应用会自动的把处理结果返回到客户端。
~~~
<?php
use Phalcon\Mvc\Micro;
use Phalcon\Http\Response;
$app = new Micro();
// 返回Response实例
$app->get('/welcome/index', function () {
$response = new Response();
$response->setStatusCode(401, "Unauthorized");
$response->setContent("Access is not authorized");
return $response;
});
~~~
### 渲染视图(Rendering Views)[](# "永久链接至标题")
[*Phalcon\Mvc\View\Simple*](#) 可用来渲染视图, 示例如下:
~~~
<?php
$app = new Phalcon\Mvc\Micro();
$app['view'] = function () {
$view = new \Phalcon\Mvc\View\Simple();
$view->setViewsDir('app/views/');
return $view;
};
// 返回渲染过的视图
$app->get('/products/show', function () use ($app) {
// 渲染视图时传递参数
echo $app['view']->render('products/show', array(
'id' => 100,
'name' => 'Artichoke'
));
});
~~~
### Error Handling[](# "永久链接至标题")
A proper response can be generated if an exception is raised in a micro handler:
~~~
<?php
$app = new Phalcon\Mvc\Micro();
$app->get('/', function () {
throw new \Exception("An error");
});
$app->error(function ($exception) {
echo "An error has occurred";
});
~~~
If the handler returns “false” the exception is stopped.
### 相关资源(Related Sources)[](# "永久链接至标题")
- [*Creating a Simple REST API*](#) 例子中讲解了如何使用微应用来创建Restfull服务:
- [Stickers Store](http://store.phalconphp.com) 也是一个简单的使用微应用的例子 [[Github](https://github.com/phalcon/store)].
|
- [索引](# "总目录")
- [下一页](# "使用命名空间(Working with Namespaces)") |
- [上一页](# "调度控制器(Dispatching Controllers)") |
- Phalcon 2.0.6文档
- API参考
- API列表
- Abstract class Phalcon\Acl
- Abstract class Phalcon\Acl\Adapter
- Class Phalcon\Acl\Adapter\Memory
- Interface Phalcon\Acl\AdapterInterface
- Class Phalcon\Acl\Exception
- Class Phalcon\Acl\Resource
- Interface Phalcon\Acl\ResourceInterface
- Class Phalcon\Acl\Role
- Interface Phalcon\Acl\RoleInterface
- Class Phalcon\Annotations\Annotation
- Abstract class Phalcon\Annotations\Adapter
- Class Phalcon\Annotations\Adapter\Apc
- Class Phalcon\Annotations\Adapter\Files
- Class Phalcon\Annotations\Adapter\Memory
- Class Phalcon\Annotations\Adapter\Xcache
- Interface Phalcon\Annotations\AdapterInterface
- Class Phalcon\Annotations\Collection
- Class Phalcon\Annotations\Exception
- Class Phalcon\Annotations\Reader
- Interface Phalcon\Annotations\ReaderInterface
- Class Phalcon\Annotations\Reflection
- Class Phalcon\Assets\Collection
- Class Phalcon\Assets\Exception
- Interface Phalcon\Assets\FilterInterface
- Class Phalcon\Assets\Filters\Cssmin
- Class Phalcon\Assets\Filters\Jsmin
- Class Phalcon\Assets\Filters\None
- Class Phalcon\Assets\Inline
- Class Phalcon\Assets\Inline\Css
- Class Phalcon\Assets\Inline\Js
- Class Phalcon\Assets\Manager
- Class Phalcon\Assets\Resource
- Class Phalcon\Assets\Resource\Css
- Class Phalcon\Assets\Resource\Js
- Abstract class Phalcon\Cache\Backend
- Class Phalcon\Cache\Backend\Apc
- Class Phalcon\Cache\Backend\File
- Class Phalcon\Cache\Backend\Libmemcached
- Class Phalcon\Cache\Backend\Memcache
- Class Phalcon\Cache\Backend\Memory
- Class Phalcon\Cache\Backend\Mongo
- Class Phalcon\Cache\Backend\Redis
- Class Phalcon\Cache\Backend\Xcache
- Interface Phalcon\Cache\BackendInterface
- Class Phalcon\Cache\Exception
- Class Phalcon\Cache\Frontend\Base64
- Class Phalcon\Cache\Frontend\Data
- Class Phalcon\Cache\Frontend\Igbinary
- Class Phalcon\Cache\Frontend\Json
- Class Phalcon\Cache\Frontend\None
- Class Phalcon\Cache\Frontend\Output
- Interface Phalcon\Cache\FrontendInterface
- Class Phalcon\Cache\Multiple
- Class Phalcon\Cli\Router\Route
- Class Phalcon\Config
- Class Phalcon\Config\Adapter\Ini
- Class Phalcon\Config\Adapter\Json
- Class Phalcon\Config\Adapter\Php
- Class Phalcon\Config\Adapter\Yaml
- Class Phalcon\Config\Exception
- Class Phalcon\Crypt
- Class Phalcon\Crypt\Exception
- Interface Phalcon\CryptInterface
- Abstract class Phalcon\Db
- Abstract class Phalcon\Db\Adapter
- Abstract class Phalcon\Db\Adapter\Pdo
- Class Phalcon\Db\Adapter\Pdo\Mysql
- Class Phalcon\Db\Adapter\Pdo\Oracle
- Class Phalcon\Db\Adapter\Pdo\Postgresql
- Class Phalcon\Db\Adapter\Pdo\Sqlite
- Interface Phalcon\Db\AdapterInterface
- Class Phalcon\Db\Column
- Interface Phalcon\Db\ColumnInterface
- Abstract class Phalcon\Db\Dialect
- Class Phalcon\Db\Dialect\Oracle
- Class Phalcon\Db\Dialect\Postgresql
- Class Phalcon\Db\Dialect\Sqlite
- Interface Phalcon\Db\DialectInterface
- Class Phalcon\Db\Exception
- Class Phalcon\Db\Index
- Interface Phalcon\Db\IndexInterface
- Class Phalcon\Db\Profiler
- Class Phalcon\Db\Profiler\Item
- Class Phalcon\Db\RawValue
- Class Phalcon\Db\Reference
- Interface Phalcon\Db\ReferenceInterface
- Class Phalcon\Db\Result\Pdo
- Interface Phalcon\Db\ResultInterface
- Class Phalcon\Debug
- Class Phalcon\Debug\Dump
- Class Phalcon\Debug\Exception
- Interface Phalcon\DiInterface
- Abstract class Phalcon\Dispatcher
- Interface Phalcon\DispatcherInterface
- Class Phalcon\Escaper
- Class Phalcon\Escaper\Exception
- Interface Phalcon\EscaperInterface
- Class Phalcon\Events\Event
- Interface Phalcon\Events\EventsAwareInterface
- Class Phalcon\Events\Exception
- Class Phalcon\Events\Manager
- Interface Phalcon\Events\ManagerInterface
- Class Phalcon\Exception
- Class Phalcon\Filter
- Class Phalcon\Filter\Exception
- Interface Phalcon\Filter\UserFilterInterface
- Interface Phalcon\FilterInterface
- Abstract class Phalcon\Flash
- Class Phalcon\Flash\Direct
- Class Phalcon\Flash\Exception
- Class Phalcon\Flash\Session
- Interface Phalcon\FlashInterface
- Class Phalcon\Forms\Form
- Abstract class Phalcon\Forms\Element
- Class Phalcon\Forms\Element\Check
- Class Phalcon\Forms\Element\Email
- Class Phalcon\Forms\Element\File
- Class Phalcon\Forms\Element\Date
- Class Phalcon\Forms\Element\Hidden
- Class Phalcon\Forms\Element\Numeric
- Class Phalcon\Forms\Element\Password
- Class Phalcon\Forms\Element\Radio
- Class Phalcon\Forms\Element\Select
- Class Phalcon\Forms\Element\Submit
- Class Phalcon\Forms\Element\Text
- Class Phalcon\Forms\Element\TextArea
- Interface Phalcon\Forms\ElementInterface
- Class Phalcon\Forms\Exception
- Class Phalcon\Forms\Manager
- Class Phalcon\Http\Cookie
- Class Phalcon\Http\Cookie\Exception
- Class Phalcon\Http\Request
- Class Phalcon\Http\Request\Exception
- Class Phalcon\Http\Request\File
- Interface Phalcon\Http\Request\FileInterface
- Interface Phalcon\Http\RequestInterface
- Class Phalcon\Http\Response
- Class Phalcon\Http\Response\Cookies
- Interface Phalcon\Http\Response\CookiesInterface
- Class Phalcon\Http\Response\Exception
- Class Phalcon\Http\Response\Headers
- Interface Phalcon\Http\Response\HeadersInterface
- Interface Phalcon\Http\ResponseInterface
- Class Phalcon\Image
- Abstract class Phalcon\Image\Adapter
- Class Phalcon\Image\Adapter\Imagick
- Interface Phalcon\Image\AdapterInterface
- Class Phalcon\Image\Exception
- Class Phalcon\Kernel
- Class Phalcon\Loader
- Class Phalcon\Loader\Exception
- Abstract class Phalcon\Logger
- Abstract class Phalcon\Logger\Adapter
- Class Phalcon\Logger\Adapter\File
- Class Phalcon\Logger\Adapter\Firephp
- Class Phalcon\Logger\Adapter\Stream
- Class Phalcon\Logger\Adapter\Syslog
- Interface Phalcon\Logger\AdapterInterface
- Class Phalcon\Logger\Exception
- Abstract class Phalcon\Logger\Formatter
- Class Phalcon\Logger\Formatter\Firephp
- Class Phalcon\Logger\Formatter\Json
- Class Phalcon\Logger\Formatter\Line
- Class Phalcon\Logger\Formatter\Syslog
- Interface Phalcon\Logger\FormatterInterface
- Class Phalcon\Logger\Item
- Class Phalcon\Logger\Multiple
- Class Phalcon\Mvc\Application
- Class Phalcon\Mvc\Application\Exception
- Abstract class Phalcon\Mvc\Collection
- Abstract class Phalcon\Mvc\Collection\Behavior
- Class Phalcon\Mvc\Collection\Behavior\SoftDelete
- Class Phalcon\Mvc\Collection\Behavior\Timestampable
- Interface Phalcon\Mvc\Collection\BehaviorInterface
- Class Phalcon\Mvc\Collection\Document
- Class Phalcon\Mvc\Collection\Exception
- Class Phalcon\Mvc\Collection\Manager
- Interface Phalcon\Mvc\Collection\ManagerInterface
- Interface Phalcon\Mvc\CollectionInterface
- Abstract class Phalcon\Mvc\Controller
- Interface Phalcon\Mvc\ControllerInterface
- Class Phalcon\Mvc\Dispatcher
- Class Phalcon\Mvc\Dispatcher\Exception
- Interface Phalcon\Mvc\DispatcherInterface
- Interface Phalcon\Mvc\EntityInterface
- Class Phalcon\Mvc\Micro
- Class Phalcon\Mvc\Micro\Collection
- Interface Phalcon\Mvc\Micro\CollectionInterface
- Class Phalcon\Mvc\Micro\Exception
- Class Phalcon\Mvc\Micro\LazyLoader
- Interface Phalcon\Mvc\Micro\MiddlewareInterface
- Abstract class Phalcon\Mvc\Model
- Abstract class Phalcon\Mvc\Model\Behavior
- Class Phalcon\Mvc\Model\Behavior\SoftDelete
- Class Phalcon\Mvc\Model\Behavior\Timestampable
- Interface Phalcon\Mvc\Model\BehaviorInterface
- Class Phalcon\Mvc\Model\Criteria
- Interface Phalcon\Mvc\Model\CriteriaInterface
- Class Phalcon\Mvc\Model\Exception
- Class Phalcon\Mvc\Model\Manager
- Interface Phalcon\Mvc\Model\ManagerInterface
- Class Phalcon\Mvc\Model\Message
- Interface Phalcon\Mvc\Model\MessageInterface
- Abstract class Phalcon\Mvc\Model\MetaData
- Class Phalcon\Mvc\Model\MetaData\Apc
- Class Phalcon\Mvc\Model\MetaData\Files
- Class Phalcon\Mvc\Model\MetaData\Libmemcached
- Class Phalcon\Mvc\Model\MetaData\Memcache
- Class Phalcon\Mvc\Model\MetaData\Memory
- Class Phalcon\Mvc\Model\MetaData\Session
- Class Phalcon\Mvc\Model\MetaData\Strategy\Annotations
- Class Phalcon\Mvc\Model\MetaData\Strategy\Introspection
- Interface Phalcon\Mvc\Model\MetaData\StrategyInterface
- Class Phalcon\Mvc\Model\MetaData\Xcache
- Interface Phalcon\Mvc\Model\MetaDataInterface
- Class Phalcon\Mvc\Model\Query
- Class Phalcon\Mvc\Model\Query\Builder
- Interface Phalcon\Mvc\Model\Query\BuilderInterface
- Abstract class Phalcon\Mvc\Model\Query\Lang
- Class Phalcon\Mvc\Model\Query\Status
- Interface Phalcon\Mvc\Model\Query\StatusInterface
- Interface Phalcon\Mvc\Model\QueryInterface
- Class Phalcon\Mvc\Model\Relation
- Interface Phalcon\Mvc\Model\RelationInterface
- Interface Phalcon\Mvc\Model\ResultInterface
- Abstract class Phalcon\Mvc\Model\Resultset
- Class Phalcon\Mvc\Model\Resultset\Complex
- Class Phalcon\Mvc\Model\Resultset\Simple
- Abstract class Phalcon\Mvc\Model\Validator
- Class Phalcon\Mvc\Model\Validator\Email
- Class Phalcon\Mvc\Model\Validator\Exclusionin
- Class Phalcon\Mvc\Model\Validator\Inclusionin
- Class Phalcon\Mvc\Model\Validator\Ip
- Class Phalcon\Mvc\Model\Validator\Numericality
- Class Phalcon\Mvc\Model\Validator\PresenceOf
- Class Phalcon\Mvc\Model\Validator\Regex
- Class Phalcon\Mvc\Model\Validator\StringLength
- Class Phalcon\Mvc\Model\Validator\Uniqueness
- Class Phalcon\Mvc\Model\Validator\Url
- Interface Phalcon\Mvc\Model\ValidatorInterface
- Interface Phalcon\Mvc\Model\ResultsetInterface
- Class Phalcon\Mvc\Model\Row
- Class Phalcon\Mvc\Model\Transaction
- Class Phalcon\Mvc\Model\Transaction\Exception
- Class Phalcon\Mvc\Model\Transaction\Failed
- Class Phalcon\Mvc\Model\Transaction\Manager
- Interface Phalcon\Mvc\Model\Transaction\ManagerInterface
- Interface Phalcon\Mvc\Model\TransactionInterface
- Class Phalcon\Mvc\Model\ValidationFailed
- Interface Phalcon\Mvc\ModelInterface
- Interface Phalcon\Mvc\ModuleDefinitionInterface
- Class Phalcon\Mvc\Router
- Class Phalcon\Mvc\Router\Annotations
- Class Phalcon\Mvc\Router\Exception
- Class Phalcon\Mvc\Router\Group
- Interface Phalcon\Mvc\Router\GroupInterface
- Class Phalcon\Mvc\Router\Route
- Interface Phalcon\Mvc\Router\RouteInterface
- Interface Phalcon\Mvc\RouterInterface
- Class Phalcon\Mvc\Url
- Class Phalcon\Mvc\Url\Exception
- Interface Phalcon\Mvc\UrlInterface
- Class Phalcon\Mvc\User\Component
- Class Phalcon\Mvc\User\Module
- Class Phalcon\Mvc\User\Plugin
- Class Phalcon\Mvc\View
- Abstract class Phalcon\Mvc\View\Engine
- Class Phalcon\Mvc\View\Engine\Php
- Class Phalcon\Mvc\View\Engine\Volt
- Class Phalcon\Mvc\View\Engine\Volt\Compiler
- Interface Phalcon\Mvc\View\EngineInterface
- Class Phalcon\Mvc\View\Exception
- Class Phalcon\Mvc\View\Simple
- Interface Phalcon\Mvc\ViewBaseInterface
- Interface Phalcon\Mvc\ViewInterface
- Abstract class Phalcon\Paginator\Adapter
- Class Phalcon\Paginator\Adapter\Model
- Class Phalcon\Paginator\Adapter\NativeArray
- Class Phalcon\Paginator\Adapter\QueryBuilder
- Interface Phalcon\Paginator\AdapterInterface
- Class Phalcon\Paginator\Exception
- Class Phalcon\Queue\Beanstalk
- Class Phalcon\Queue\Beanstalk\Job
- Final class Phalcon\Registry
- Class Phalcon\Security
- Class Phalcon\Security\Exception
- Abstract class Phalcon\Session
- Abstract class Phalcon\Session\Adapter
- Class Phalcon\Session\Adapter\Files
- Class Phalcon\Session\Adapter\Libmemcached
- Class Phalcon\Session\Adapter\Memcache
- Interface Phalcon\Session\AdapterInterface
- Class Phalcon\Session\Bag
- Interface Phalcon\Session\BagInterface
- Class Phalcon\Session\Exception
- Class Phalcon\Tag
- Class Phalcon\Tag\Exception
- Abstract class Phalcon\Tag\Select
- Abstract class Phalcon\Text
- Abstract class Phalcon\Translate
- Abstract class Phalcon\Translate\Adapter
- Class Phalcon\Translate\Adapter\Csv
- Class Phalcon\Translate\Adapter\Gettext
- Class Phalcon\Translate\Adapter\NativeArray
- Interface Phalcon\Translate\AdapterInterface
- Class Phalcon\Translate\Exception
- Class Phalcon\Validation
- Class Phalcon\Validation\Exception
- Class Phalcon\Validation\Message
- Class Phalcon\Validation\Message\Group
- Interface Phalcon\Validation\MessageInterface
- Abstract class Phalcon\Validation\Validator
- Class Phalcon\Validation\Validator\Alnum
- Class Phalcon\Validation\Validator\Alpha
- Class Phalcon\Validation\Validator\Between
- Class Phalcon\Validation\Validator\Confirmation
- Class Phalcon\Validation\Validator\Digit
- Class Phalcon\Validation\Validator\Email
- Class Phalcon\Validation\Validator\ExclusionIn
- Class Phalcon\Validation\Validator\File
- Class Phalcon\Validation\Validator\Identical
- Class Phalcon\Validation\Validator\InclusionIn
- Class Phalcon\Validation\Validator\Numericality
- Class Phalcon\Validation\Validator\PresenceOf
- Class Phalcon\Validation\Validator\Regex
- Class Phalcon\Validation\Validator\StringLength
- Class Phalcon\Validation\Validator\Uniqueness
- Class Phalcon\Validation\Validator\Url
- Interface Phalcon\Validation\ValidatorInterface
- Class Phalcon\Version
- 参考手册
- 安装(Installation)
- 教程 1:让我们通过例子来学习(Tutorial 1: Let’s learn by example)
- 教程 2:Introducing INVO(Tutorial 2: Introducing INVO)
- 教程 3: Securing INVO
- 教程 4: Using CRUDs
- 教程 5: Customizing INVO
- 教程 6: Vkuró
- 教程 7:创建简单的 REST API(Tutorial 7: Creating a Simple REST API)
- 示例列表(List of examples)
- 依赖注入与服务定位器(Dependency Injection/Service Location)
- MVC 架构(The MVC Architecture)
- 使用控制器(Using Controllers)
- 使用模型(Working with Models)
- 模型元数据(Models Meta-Data)
- 事务管理(Model Transactions)
- Phalcon 查询语言(Phalcon Query Language (PHQL))
- 缓存对象关系映射(Caching in the ORM)
- 对象文档映射 ODM (Object-Document Mapper)
- 使用视图(Using Views)
- 视图助手(View Helpers)
- 资源文件管理(Assets Management)
- Volt 模版引擎(Volt: Template Engine)
- MVC 应用(MVC Applications)
- 路由(Routing)
- 调度控制器(Dispatching Controllers)
- 微应用(Micro Applications)
- 使用命名空间(Working with Namespaces)
- 事件管理器(Events Manager)
- Request Environment
- 返回响应(Returning Responses)
- Cookie 管理(Cookies Management)
- 生成 URL 和 路径(Generating URLs and Paths)
- 闪存消息(Flashing Messages)
- 使用 Session 存储数据(Storing data in Session)
- 过滤与清理(Filtering and Sanitizing)
- 上下文编码(Contextual Escaping)
- 验证(Validation)
- 表单(Forms)
- 读取配置(Reading Configurations)
- 分页(Pagination)
- 使用缓存提高性能(Improving Performance with Cache)
- 安全(Security)
- Encryption/Decryption
- 访问控制列表 ACL(Access Control Lists ACL)
- 多语言支持(Multi-lingual Support)
- Universal Class Loader
- 日志记录(Logging)
- 注释解析器(Annotations Parser)
- 命令行应用(Command Line Applications)
- 队列(Queueing)
- 数据库抽象层(Database Abstraction Layer)
- 国际化(Internationalization)
- 数据库迁移(Database Migrations)
- 调试应用程序(Debugging Applications)
- Phalcon 开发工具(Phalcon Developer Tools)
- 提高性能:下一步该做什么?(Increasing Performance: What’s next?)
- 单元测试(Unit testing)
- 授权(License)