不知道你們有沒有用過openPNE,其實我們可以使用openPNE創建過專案。今天我們就來介紹openPNE創建過專案的方法,有需要的可以參考參考。
使在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{}
##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
建立資料庫表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') ), ); } } ?>
#
vote: : opVotePluginFrontendRouteCollection options: { name: vote }
推薦學習:php影片教學
####以上是用openPNE怎麼才能建立一個項目的詳細內容。更多資訊請關注PHP中文網其他相關文章!