$ pwd
/Applications/MAMP/htdocs
$ phalcon create-project store
产生以上推荐的项目结构:
您可以添加参数--help来获得关于某个脚本使用的帮助:
$ phalcon project --help
Phalcon DevTools (3.0.0)
Help:
Creates a project
Usage:
project [name] [type][directory] [enable-webtools]
Arguments:
help Shows this help text
Example
phalcon project store simple
Options:
--name Name of the new project
--enable-webtools Determines if webtools should be enabled [optional]
--directory=s Base path on which project will be created [optional]
--type=s Type of the application to be generated (cli, micro, simple, modules)--template-path=s Specify a template path [optional]
--use-config-ini Use a ini file as configuration file [optional]
--trace Shows the trace of the framework in case of exception. [optional]
--help Shows this help
从web服务器访问项目将显示:
生成控制器
The command create-controller generates controller skeleton structures. It’s important to invoke this command inside a directory that already has a Phalcon project.
使用开发人员工具生成项目时。 A configuration file can be found in app/config/config.php. 要生成模型或脚手架,需要更改连接到数据库的设置。
Change the database section in your config.php file:
<?phpdefined('BASE_PATH')||define('BASE_PATH',getenv('BASE_PATH')?:realpath(dirname(__FILE__).'/../..'));defined('APP_PATH')||define('APP_PATH',BASE_PATH.'/app');returnnew\Phalcon\Config(['database'=>['adapter'=>'Mysql','host'=>'localhost','username'=>'root','password'=>'secret','dbname'=>'test','charset'=>'utf8',],'application'=>['appDir'=>APP_PATH.'/','controllersDir'=>APP_PATH.'/controllers/','modelsDir'=>APP_PATH.'/models/','migrationsDir'=>APP_PATH.'/migrations/','viewsDir'=>APP_PATH.'/views/','pluginsDir'=>APP_PATH.'/plugins/','libraryDir'=>APP_PATH.'/library/','cacheDir'=>BASE_PATH.'/cache/',// This allows the baseUri to be understand project paths that are not in the root directory// of the webpspace. This will break if the public/index.php entry point is moved or// possibly if the web server rewrite rules are changed. This can also be set to a static path.'baseUri'=>preg_replace('/public([\/\\])index.php$/','',$_SERVER["PHP_SELF"]),]]);
Generating Models
创建模型有几种方法。 您可以从默认数据库连接或有选择地创建所有模型。 Models can have public attributes for the field representations or setters/getters can be used.
Options:
--name=s Table name
--schema=s Name of the schema. [optional]
--namespace=s Model's namespace [optional]
--get-set Attributes will be protected and have setters/getters. [optional]
--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]
--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]
--mapcolumn Get some code for map columns. [optional]
--abstract Abstract Model [optional]
<?phpusePhalcon\Mvc\Model;classProductsextendsModel{/**
* @var integer
*/protected$id;/**
* @var integer
*/protected$typesId;/**
* @var string
*/protected$name;/**
* @var string
*/protected$price;/**
* @var integer
*/protected$quantity;/**
* @var string
*/protected$status;/**
* Method to set the value of field id
*
* @param integer $id
*/publicfunctionsetId($id){$this->id=$id;}/**
* Method to set the value of field typesId
*
* @param integer $typesId
*/publicfunctionsetTypesId($typesId){$this->typesId=$typesId;}// .../**
* Returns the value of field status
*
* @return string
*/publicfunctiongetStatus(){return$this->status;}}
After performing a search, a pager component is available to show paged results. Use the “Edit” or “Delete” links in front of each result to perform such actions.
工具的 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:
将工具与 phpstorm ide 集成
The screencast below shows how to integrate developer tools with the PhpStorm IDE. 配置步骤可以很容易地适应 php 的其他 ide。