Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 44 additions & 52 deletions zh/reference/tools.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
Phalcon Developer Tools
=======================
These tools are a collection of useful scripts to generate skeleton code. Core components of your application can be generated with
a simple command, allowing you to easily develop applications using Phalcon.
Phalcon 开发工具
================
开发工具是生成脚手架代码的一系列脚本。使用简单的命令生成应用的核心代码,使得 Phalcon 开发过程更加容易。

.. highlights::
**Important:** Phalcon Framework version 0.5.0 or greater is needed to use developer tools. It is highly recommended
to use PHP 5.3.6 or greater. If you prefer to use the web version instead of the console, this `blog post`_ offers more information.
**重要提醒:** Phalcon 框架 0.5.0 或以上版本需要使用本开发工具。强烈建议使用 PHP 5.3.6 或更高版本。如果你不需要命令行脚本而习惯网页工具,请参阅该`博客`_。

Download
--------
You can download or clone a cross platform package containing the developer tools from Github_.
下载
----
可以从 Github_ 下载或克隆跨平台的开发工具包。

Installation
^^^^^^^^^^^^
These are detailed instructions on how to install the developer tools on different platforms:
安装
^^^^
不同平台下开发工具的详细安装说明如下:

.. toctree::
:maxdepth: 1
Expand All @@ -22,45 +20,43 @@ These are detailed instructions on how to install the developer tools on differe
mactools
linuxtools

Getting Available Commands
--------------------------
You can get a list of available commands in Phalcon tools by typing: phalcon commands
显示可用的命令
--------------
输入 phalcon commands 可以显示一个可用的命令列表:

.. figure:: ../_static/img/tools-4.png
:align: center

Generating a Project Skeleton
-----------------------------
You can use Phalcon tools to generate pre-defined project skeletons for your applications with Phalcon framework. By default the
project skeleton generator will use mod_rewrite for Apache. Type the following command on your web server document root:
生成项目脚手架
--------------
使用 Phalcon 工具可以自动生成一个为 Phalcon 框架预先编写好的项目脚手架。默认情况下,项目脚手架生成器会使用 Apache mod_rewrite 模块。在 Web 服务器文档根目录下输入下列命令:

.. figure:: ../_static/img/tools-1.png
:align: center

The above recommended project structure was generated:
生成的项目目录结构如下:

.. figure:: ../_static/img/tools-2.png
:align: center

You could add the parameter *--help* to get help on the usage of a certain script:
使用 *--help* 命令参数查看命令帮助:

.. figure:: ../_static/img/tools-3.png
:align: center

Accessing the project from the web server will show you:
在浏览器中访问该项目显示如下:

.. figure:: ../_static/img/tools-6.png
:align: center

Generating Controllers
----------------------
The command "create-controller" generates controller skeleton structures. It's important to invoke this command inside a directory
that already has a Phalcon project.
生成控制器
----------
命令 "create-controller" 生成控制器脚手架。需要注意的是,必须在一个 Phalcon 项目目录下使用该命令。

.. figure:: ../_static/img/tools-5.png
:align: center

The following code is generated by the script:
脚本会生成下面的代码:

.. code-block:: php

Expand All @@ -76,12 +72,11 @@ The following code is generated by the script:

}

Preparing Database Settings
---------------------------
When a project is generated using developer tools. A configuration file can be found in *app/config/config.ini* To generate models
or scaffold, you will need to change the settings used to connect to your database.
数据库预配置
------------
开发工具生成项目时,也会自动创建 *app/config/config.ini* 配置文件。在使用开发工具生成模型和 CURD 增删改查脚手架前,必须更改数据库的设置以便正确连接到数据库。

Change the database section in your config.ini file:
更改 config.ini 文件的数据库部分:

.. code-block:: ini

Expand All @@ -98,15 +93,14 @@ Change the database section in your config.ini file:
viewsDir = "../app/views/"
baseUri = "/store/"

Generating Models
-----------------
There are several ways to create models. You can create all models from the default database connection or some selectively. Models
can have public attributes for the field representations or setters/getters can be used. The simplest way to generate a model is:
生成模型
--------
创建模型有好几种方法。可以从默认的数据库连接创建所有模型,也可以有选择性的创建。每一个表字段可以声明为模型的 public 属性,也可以使用 setters/getters 来操作。最简单的生成模型方法如下:

.. figure:: ../_static/img/tools-7.png
:align: center

All table fields are declared public for direct access.
所有的表字段都被声明为可供直接访问的 public 属性。

.. code-block:: php

Expand Down Expand Up @@ -147,8 +141,7 @@ All table fields are declared public for direct access.

}

By adding the *--get-set* you can generate the fields with protected variables and public setter/getter methods. Those methods
can help in business logic implementation within the setter/getter methods.
使用 *--get-set* 参数可以将表字段声明为 protected,同时生成 public setter/getter 方法。在业务逻辑中使用相应的 setter/getter 方法。

.. code-block:: php

Expand Down Expand Up @@ -219,16 +212,15 @@ can help in business logic implementation within the setter/getter methods.

}

A nice feature of the model generator is that it keeps changes made by the developer between code generations. This allows the
addition or removal of fields and properties, without worrying about losing changes made to the model itself.
The following screencast shows you how it works:
模型生成器的好处在于开发者能使用生成器来控制变更。生成器增加或删除字段和属性,而不用担心忘记更改模型的内容。
详细的工作原理可以参阅下面的视频演示:

.. raw:: html

<div align="center"><iframe src="http://player.vimeo.com/video/39213020" width="500" height="266" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>

Scaffold a CRUD
---------------
生成 CRUD 增删改查脚手架
------------------------
Scaffolding is a quick way to generate some of the major pieces of an application. If you want to create the models, views, and
controllers for a new resource in a single operation, scaffolding is the tool for the job.

Expand Down Expand Up @@ -275,27 +267,27 @@ After performing a search, a pager component is available to show paged results.
.. figure:: ../_static/img/tools-12.png
:align: center

Web Interface to Tools
----------------------
Web 界面工具
-------------
Also, if you prefer, it's possible to use Phalcon Developer Tools from a web interface. Check out the following screencast to figure out how it works:

.. raw:: html

<div align="center"><iframe src="http://player.vimeo.com/video/42367665" width="500" height="266" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>

Integrating Tools with PhpStorm IDE
-----------------------------------
PhpStorm IDE 内置工具
---------------------
The screencast below shows how to integrate developer tools with the `PhpStorm IDE`_. The configuration steps could be easily adapted to other IDEs for PHP.

.. raw:: html

<div align="center"><iframe src="http://player.vimeo.com/video/43455647" width="500" height="266" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>

Conclusion
----------
Phalcon Developer Tools provides an easy way to generate code for your application, reducing development time and potential coding errors.
结论
-----
Phalcon 开发工具提供简单的方式生成应用代码,减少开发时间并降低潜在的编码错误风险。

.. _blog post: http://blog.phalconphp.com/post/23251010409/dont-like-command-line-and-consoles-no-problem
.. _博客: http://blog.phalconphp.com/post/23251010409/dont-like-command-line-and-consoles-no-problem
.. _Github: https://github.com/phalcon/phalcon-devtools
.. _Bootstrap: http://twitter.github.com/bootstrap/
.. _PhpStorm IDE: http://www.jetbrains.com/phpstorm/
2 changes: 1 addition & 1 deletion zh/reference/tutorial-invo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ INVO应用程序分为两部分,即通常我们说的前台后台。前台部

标准路由器
---------------
INVO使用标准的内奸路由器组件,此路由的匹配模式如下 /:controller/:action/:params ,这意味着,URL中的第一部分是控制器,第二个是action方法。
INVO使用标准的内建路由器组件,此路由的匹配模式如下 /:controller/:action/:params ,这意味着,URL中的第一部分是控制器,第二个是action方法。

路由 /session/register 将要执行SessionController中的RegisterAction方法

Expand Down