# phalcon_store **Repository Path**: lisgroup/phalcon_store ## Basic Information - **Project Name**: phalcon_store - **Description**: phalcon框架开发测试 - **Primary Language**: PHP - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-07-14 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 开发流程 ## 一、Phalcon 开发工具的使用 ### 1.获取可用的命令(Getting Available Commands) 按照官方方法安装开发工具 [Github地址](https://github.com/phalcon/phalcon-devtools) ,然后在控制台上输入如下命令: `phalcon commands` ``` $ phalcon commands Phalcon DevTools (3.2.0) Available commands: info (alias of: i) commands (alias of: list, enumerate) controller (alias of: create-controller) module (alias of: create-module) model (alias of: create-model) all-models (alias of: create-all-models) project (alias of: create-project) scaffold (alias of: create-scaffold) migration (alias of: create-migration) webtools (alias of: create-webtools) console (alias of: shell, psysh) ``` ### 2.生成项目框架(Generating a Project Skeleton) 我们可以使用Phalcon开发辅助工具生成预先定义的项目架构。 默认情况下,phalcon开发辅助工具会使用apache的mod_rewrite来生成程序的骨架. 要创建项目我们只需要在我们的 web服务器根目录下输入如下命令: ``` $ pwd /home/www $ phalcon create-project store ``` 执行命令后会生成如下的文档结构的项目: ![](http://www.iphalcon.cn/_images/tools-2.png "文档结构"!) ### 3.生成控制器(Generating Controllers) `$ phalcon create-controller --name test` 上面代码会生成如下代码: ```php [ 'adapter' => 'Mysql', 'host' => 'localhost', 'username' => 'root', 'password' => 'root', 'dbname' => 'test', 'charset' => 'utf8', ], ```` ### 5. 生成模型(Generating Models) > 注意:执行以下命令需正确配置数据库,表结构见 test.sql 文件 ` phalcon model products ` ``` 使用phalcon开发辅助工具我们可以有若干种方式来生成模型。 可以有选择的生成若干个模型或是全部生成。 亦可以指定生成公有属性或是生成setter和getter方法。 Options: --name=s Table name 表名 --schema=s Name of the schema. [optional] schema名 --namespace=s Model’s namespace [optional] 模型命名空间 --get-set Attributes will be protected and have setters/getters. [optional] 设置字段访问属性为私有 并添加setters/getters方法 --extends=s Model extends the class name supplied [optional] 指定扩展类名 --excludefields=l Excludes fields defined in a comma separated list [optional] --doc Helps to improve code completion on IDEs [optional] 辅助IDE的自动完成功能 --directory=s Base path on which project will be created [optional] 项目的根目录 --force Rewrite the model. [optional] 重写模型 --trace Shows the trace of the framework in case of exception. [optional] 出错时显示框架trace信息 --mapcolumn Get some code for map columns. [optional] 生成字映射的代码 --abstract Abstract Model [optional] 抽象模型 ``` ### 6.生成基本的 CRUD(Scaffold a CRUD) `$ phalcon scaffold --table-name products` > 访问 http://localhost/store/products 即可查看效果。