首頁  >  文章  >  後端開發  >  用openPNE怎麼才能建立一個項目

用openPNE怎麼才能建立一個項目

醉折花枝作酒筹
醉折花枝作酒筹轉載
2021-07-16 15:56:091961瀏覽

不知道你們有沒有用過openPNE,其實我們可以使用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

建立資料庫表


建立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 = (
      &#39;vote_list&#39; =>  sfRequestRoute(    
        &#39;/vote&#39;,                                    (&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;index&#39;),            (&#39;sf_method&#39; => (&#39;get&#39;))
      ),
      &#39;vote_new&#39; =>  sfRequestRoute(
        &#39;/vote/new&#39;,
(&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;new&#39;),
(&#39;sf_method&#39; => (&#39;get&#39;))
      ),
      &#39;vote_create&#39; =>  sfRequestRoute(
        &#39;/vote/create&#39;,
(&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;create&#39;),
(&#39;sf_method&#39; => (&#39;post&#39;))
      ),
      &#39;vote_edit&#39; =>  sfDoctrineRoute(
        &#39;/vote/edit/:id&#39;,            (&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;edit&#39;),
(&#39;id&#39; => &#39;\d+&#39;, &#39;sf_method&#39; => (&#39;get&#39;)),
(&#39;model&#39; => &#39;VoteQuestion&#39;, &#39;type&#39; => &#39;object&#39;)
      ),
      &#39;vote_update&#39; =>  sfDoctrineRoute(
        &#39;/vote/update/:id&#39;,
(&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;update&#39;),
(&#39;id&#39; => &#39;\d+&#39;, &#39;sf_method&#39; => (&#39;post&#39;)),
(&#39;model&#39; => &#39;VoteQuestion&#39;, &#39;type&#39; => &#39;object&#39;)
      ),
      &#39;vote_show&#39; =>  sfDoctrineRoute(
        &#39;/vote/show/:id&#39;,
(&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;show&#39;),
(&#39;id&#39; => &#39;\d+&#39;, &#39;sf_method&#39; => (&#39;get&#39;)),
(&#39;model&#39; => &#39;VoteQuestion&#39;, &#39;type&#39; => &#39;object&#39;)
      ),
      &#39;vote_post&#39; =>  sfDoctrineRoute(
        &#39;/vote/post/:id&#39;,
(&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;post&#39;),
(&#39;id&#39; => &#39;\d+&#39;, &#39;sf_method&#39; => (&#39;post&#39;)),
(&#39;model&#39; => &#39;VoteQuestion&#39;, &#39;type&#39; => &#39;object&#39;)
      ),
      &#39;vote_delete_confirm&#39; =>  sfDoctrineRoute(
        &#39;/vote/delete/:id&#39;,
(&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;deleteConfirm&#39;),
(&#39;id&#39; => &#39;\d+&#39;, &#39;sf_method&#39; => (&#39;get&#39;)),
(&#39;model&#39; => &#39;VoteQuestion&#39;, &#39;type&#39; => &#39;object&#39;)
      ),
      &#39;vote_delete&#39; =>  sfDoctrineRoute(
        &#39;/vote/delete/:id&#39;,
(&#39;module&#39; => &#39;vote&#39;, &#39;action&#39; => &#39;delete&#39;),
(&#39;id&#39; => &#39;\d+&#39;, &#39;sf_method&#39; => (&#39;post&#39;)),
(&#39;model&#39; => &#39;VoteQuestion&#39;, &#39;type&#39; => &#39;object&#39;)
      ),
     &#39;vote_nodefaults&#39; =>  sfRoute(
        &#39;/vote/*&#39;,
(&#39;module&#39; => &#39;default&#39;, &#39;action&#39; => &#39;error&#39;)
      ),
    );
  }
}
?>

建立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檔案也可,將依預設路由存取

推薦學習:php影片教學

####

以上是用openPNE怎麼才能建立一個項目的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:cnblogs.com。如有侵權,請聯絡admin@php.cn刪除