使在cmd命令符下找到php命令
打开“我的电脑”->“属性”->“高级”->“环境变量”->“系统变量”->“path”,编辑其值,在前面
增加下面的路径地址:
D:\wamp\bin\php\php5.3.0; ===========php编译安装目录
将php.ini复制到C:\Windows 目录下
symfony简单的建程序
将下载好的symfony压缩包解压缩到www文件夹下起名symfony
命令行输入
e:打开E盘根目录 cd..\.. ===========返回上两级,或打开指定目录 cd wamp\www\symfony ===========打开指定目录 php data\bin\symfony -V ===========查询symfony版本信息 php data\bin\symfony generate:project newProject ===========在www\symfony文件夹下生成一个名叫newProject的新项目 php data\bin\symfony generate:app myApp ===========在该项目的APPS文件夹下生成一个名叫myApp新程序 php data\bin\symfony generate:module myApp myModule ===========在myApp程序文件夹下建立一个名叫myModule的新模块
php调用的symfony命令打开的是相对当前目录存放symfony命令的目录
在动作类中写的动作方法与对应模板的访问路径 mymodule模块名 myAction动作方法名
OpenPNE 安装
将下载好的压缩包解压缩到服务器目录
查找 ProjectConfiguration..php.sample改名成ProjectConfiguration..php
Apache服务打开rewrite模块
cmd命令符下打开openPNE所在文件夹,输入
php symfony openpne:install
PHP的APC扩展:如有需要将115中的php_apc.dll下载到wamp\bin\php\php5.3.0\ext目录下
打开php扩展的php_apc,打开php.ini,找到extension=php_apc.dll并在下一行添加
apc.enabled=0 apc.shm_segments=0 apc.enable_cli=0
如果根目录有cache文件夹把cache中的内容清空
创建一个程序
cmd输入
php symfony opGenerate:plugin opVotePlugin ===========创建一个vote插件程序 php symfony opGenerate:app opVotePlugin pc_frontend ===========为vote插件程序创建电脑前台文件夹 php symfony opGenerate:module opVotePlugin pc_frontend vote ===========在vote插件程序电脑前台文件夹内创建vote模块 php symfony cc ===========清除一次缓存
action动作及访问权限
在plugins\opVotePlugin\lib\actions目录下创建一个opVotePluginVoteActions..php文件
文件中写类class opVotePluginVoteActions sfActions{}
然后在opVotePlugin\apps\pc_frontend\modules\vote\actions\actions..php文件中的类继承刚才写的类
voteActions opVotePluginVoteActions{}
不仅电脑前台pc_frontend文件夹内,在opVotePlugin\apps下的所有手机电脑前后台模块动作都可以继承这个类,实现一个类管理多个前端
建立plugins\opVotePlugin\apps\pc_frontend\modules\vote\config\security.yml文件然后输入
all:
is_secure: on
credentials: SNSMember
表示此模块需要验证,只有会员才能访问
在opVotePluginVoteActions类中写一个动作
executeShow(sfWebRequest ){}
然后创建plugins\opVotePlugin\apps\pc_frontend\modules\vote\templates\showSuccess.php
执行一次命令php symfony cc
建立数据库表
创建plugins/opVotePlugin/config/doctrine/schema.yml文件,输入
options: charset: utf8 VoteQuestion: actAs: [Timestampable] columns: id: { type: (4), primary: , autoincrement: } member_id: { type: (4), notnull: } title: { type: (140), notnull: } body: { type: } relations: Member: { onDelete: cascade } VoteQuestionOption: columns: id: { type: (4), primary: , autoincrement: } vote_question_id: { type: (4), notnull: } body: { type: (140), notnull: } relations: VoteQuestion: { onDelete: cascade, foreignAlias: VoteQuestionOptions } VoteAnswer: actAs: [Timestampable] columns: id: { type: (4), primary: , autoincrement: } member_id: { type: (4), notnull: } vote_question_id: { type: (4), notnull: } vote_question_option_id: { type: (4), notnull: } body: { type: } relations: Member: { onDelete: cascade } VoteQuestion: { onDelete: cascade, foreignAlias: VoteAnswers } VoteQuestionOption: { onDelete: cascade, foreignAlias: VoteAnswers }
表示分别创建了vote_question,vote_question_option,vote_answer三个表其中的relations表示设立外键关联
此时执行命令php symfony openpne:install将重新安装openPNE并创建前面三张表
之后再执行一次php symfony doctrine:build --all --and-load 重新插入数据
路由规则
创建plugins/opVotePlugin/lib/routing/opVotePluginFrontendCollection..php
输入
<?php opVotePluginFrontendRouteCollection sfRouteCollection { __construct( ) { parent::__construct(); ->routes = ( 'vote_list' => sfRequestRoute( '/vote', ('module' => 'vote', 'action' => 'index'), ('sf_method' => ('get')) ), 'vote_new' => sfRequestRoute( '/vote/new', ('module' => 'vote', 'action' => 'new'), ('sf_method' => ('get')) ), 'vote_create' => sfRequestRoute( '/vote/create', ('module' => 'vote', 'action' => 'create'), ('sf_method' => ('post')) ), 'vote_edit' => sfDoctrineRoute( '/vote/edit/:id', ('module' => 'vote', 'action' => 'edit'), ('id' => '\d+', 'sf_method' => ('get')), ('model' => 'VoteQuestion', 'type' => 'object') ), 'vote_update' => sfDoctrineRoute( '/vote/update/:id', ('module' => 'vote', 'action' => 'update'), ('id' => '\d+', 'sf_method' => ('post')), ('model' => 'VoteQuestion', 'type' => 'object') ), 'vote_show' => sfDoctrineRoute( '/vote/show/:id', ('module' => 'vote', 'action' => 'show'), ('id' => '\d+', 'sf_method' => ('get')), ('model' => 'VoteQuestion', 'type' => 'object') ), 'vote_post' => sfDoctrineRoute( '/vote/post/:id', ('module' => 'vote', 'action' => 'post'), ('id' => '\d+', 'sf_method' => ('post')), ('model' => 'VoteQuestion', 'type' => 'object') ), 'vote_delete_confirm' => sfDoctrineRoute( '/vote/delete/:id', ('module' => 'vote', 'action' => 'deleteConfirm'), ('id' => '\d+', 'sf_method' => ('get')), ('model' => 'VoteQuestion', 'type' => 'object') ), 'vote_delete' => sfDoctrineRoute( '/vote/delete/:id', ('module' => 'vote', 'action' => 'delete'), ('id' => '\d+', 'sf_method' => ('post')), ('model' => 'VoteQuestion', 'type' => 'object') ), 'vote_nodefaults' => sfRoute( '/vote/*', ('module' => 'default', 'action' => 'error') ), ); } } ?>
创建plugins/opVotePlugin/apps/pc_frontend/config/routing.yml
输入
vote: : opVotePluginFrontendRouteCollection options: { name: vote }
指定由哪个类来设定路由规则
输入命令php symfony cc
输入命令php symfony app:routes pc_frontend 查看路由是否设定成功
不创建opVotePluginFrontendCollection..php与routing.yml文件也可,将按默认路由访问