久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

PHP MVC 框架的文件夾結(jié)構(gòu)......我這樣做對(duì)嗎?

Folder structure of a PHP MVC framework... am I doing this right?(PHP MVC 框架的文件夾結(jié)構(gòu)......我這樣做對(duì)嗎?)
本文介紹了PHP MVC 框架的文件夾結(jié)構(gòu)......我這樣做對(duì)嗎?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我目前正在開(kāi)發(fā)我自己的 PHP 框架,我需要一些幫助來(lái)確定我是否朝著正確的方向前進(jìn)...

I'm currently working on my own PHP Framework, and I need some help figuring out if I'm going in the right direction or not...

該框架既供我自己使用,又可進(jìn)一步提高我的 PHP 技能.我遇到了許多問(wèn)題,通過(guò)克服它們,我學(xué)到了很多東西,并且喜歡能夠從無(wú)到有創(chuàng)造一些東西,所以我不想看到像只使用 Zend"這樣的答案!;)

The framework is both for my own use and to generally advance my PHP skills further. I've encountered numerous problems that by overcoming them I have learned a great deal, and love being able to create something from nothing, so I'd rather not see answers like "Just use Zend"! ;)

我已經(jīng)閱讀了很多關(guān)于 Stack Overflow 和其他網(wǎng)站的文章,但不能完全得到我需要的正確答案,所以希望有人能給我一些有用的建議!

I have read a bunch of articles both on Stack Overflow and a bunch of other sites, but can't quite get the right answer I need, so hopefully someone can give me some helpful advice!

我嘗試了幾種不同的解決方案,但我最終讓自己感到困惑,我不確定現(xiàn)在該往哪個(gè)方向發(fā)展!無(wú)法完全理解這一切...

I've tried a few different solutions, but I've just ended up confusing myself and I'm not sure which direction to go now! Can't quite get my head around it all...

'理論'框架結(jié)構(gòu)

- .htaccess
- index.php
- private/
    - app/
        - bootstrap.php
        - modules/
            - default/
                - controllers/
                    - pages.php
                    - index.php
                - models/
                - views/
            - admin/
                - controllers/
                - models/
                - views/
    - config/
        - config.php
        - autoloader.php
    - lib/
        - Some_Library
            - Class1
                - class1.php
            - Class2
                - class2.php
- public/
    - css
    - images
    - scripts

詳情

  • index.php 是主文件,每個(gè)請(qǐng)求都通過(guò) .htaccess 路由到這里.
  • private/ 顯然不能公開(kāi)訪問(wèn).
  • public/ 包含所有公共文件.
  • app/ 包含所有特定于應(yīng)用的代碼.
  • lib/ 可以包含 Zend 或其他庫(kù)(我也在自己開(kāi)發(fā)),以使用自動(dòng)加載器調(diào)用
  • bootstrap.php 是特定于應(yīng)用程序的代碼... 我需要這個(gè)嗎?主要的'index.php'就夠了嗎?.
  • modules/ 將包含每個(gè)模塊... 我需要模塊嗎?.
  • default/ 是包含大多數(shù)請(qǐng)求的 MVC 的默認(rèn)模塊(當(dāng)admin"不是 URL 的第一部分時(shí)使用).
  • admin/ 是包含管理部分 MVC 的模塊.
  • index.php is the main file, where every request is routed to with .htaccess.
  • private/ can't be accessed publicly, obviously.
  • public/ contains all the public files.
  • app/ contains all app-specific code.
  • lib/ could contain Zend or another library (I'm also working on my own), to be called with autoloaders
  • bootstrap.php is the app-specific code... Do I need this? is the main 'index.php' enough?.
  • modules/ would contain each module... Do I need modules at all?.
  • default/ is the default module that will contain the MVC's for most requests (used when 'admin' isn't the first part of the URL).
  • admin/ is the module that will contain the MVC's for the admin section.

無(wú)論如何,對(duì)于我的問(wèn)題...

我認(rèn)為將管理部分與網(wǎng)站的其余部分分開(kāi)會(huì)更好,但這就是我陷入困境的地方.我已經(jīng)制作了上述結(jié)構(gòu)來(lái)使用它,但我不確定這是否是最有效的方法.

I thought it would be better to separate the admin section from the rest of the website, but that's where I'm getting stuck. I have made the above structure to work with it, but I'm not sure if this is the most effective way.

如果請(qǐng)求 site.com/videos/view/1/ 來(lái)到我的網(wǎng)站..

If a request site.com/videos/view/1/ comes to my site..

模塊:默認(rèn)控制器:視頻操作:查看參數(shù):數(shù)組('1')

Module: Default Controller: Videos Action: View Params: array( '1' )

如果請(qǐng)求 site.com/admin/pages/view/1/ 來(lái)到我的網(wǎng)站..

and if the request site.com/admin/pages/view/1/ comes to my site..

模塊:管理員控制器:頁(yè)面操作:查看參數(shù):數(shù)組('1')

Module: Admin Controller: Pages Action: View Params: array( '1' )

這是解決這個(gè)問(wèn)題的正確方法嗎?或者我是否過(guò)度復(fù)雜化并做了一些不值得做的事情?

Is this the right way to go about this? Or am I over-complicating it and doing something that's not worth doing?

我的管理部分是否應(yīng)該有一個(gè)完全獨(dú)立的應(yīng)用程序框架...?我什至需要將管理部分的 MVC 與其他部分分開(kāi)嗎?

Should I have a completely separate application framework for my admin section...? Do I even need to separate the admin section's MVC's from the rest of it all?

抱歉問(wèn)了這么大的問(wèn)題,只是想為您提供盡可能多的信息!隨意回答你能回答的部分=P

Sorry for the massive question, just wanted to give you as much info as possible! Feel free to answer whichever part you can =P

推薦答案

一個(gè)管理路由的解決方案是 CakePHP 所做的,您首先為管理字符串定義一個(gè)配置然后在您的控制器中使用具有特定命名轉(zhuǎn)換的動(dòng)作

One Solution for admin routing is what CakePHP does, you first define a configuration for the admin string and then in your controller use actions with a specific naming convertion

//Configuration ============================
Configure::write("admin_routing" , true );
Configure::write("admin_prefix"  , "admin" );

//Controller ===============================
class MyController extends AppController{

    function index(){
      //Will map to /mycontroller/
    }


    function admin_index(){
      //Will map to /admin/mycontroller/
    }

}

您可以使用路由系統(tǒng)對(duì)此進(jìn)行概括看看你最喜歡的框架是怎么做的

You can generalize this by using a routing system just look how your favorite framework does it

另外一點(diǎn)

  1. modules 文件夾似乎不需要
  2. 我同意 antpaw 您應(yīng)該添加一個(gè)全局視圖和模型文件夾,以便在應(yīng)用程序之間共享它們
  3. 我不明白為什么自動(dòng)加載器在 config 目錄中而不是 lib 目錄的一部分,您也可以將 boostrap.php 移動(dòng)到 config 目錄

希望能幫到你

這篇關(guān)于PHP MVC 框架的文件夾結(jié)構(gòu)......我這樣做對(duì)嗎?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Action View Helper in Zend - Work around?(Zend 中的動(dòng)作視圖助手 - 解決方法?)
Is this a good way to match URI to class/method in PHP for MVC(這是將 URI 與 PHP 中用于 MVC 的類/方法匹配的好方法嗎)
Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?(我在哪里保存 Zend Framework 中的部分(視圖),以便我的應(yīng)用程序中的所有視圖都可以訪問(wèn)?) - IT屋-程序員軟件開(kāi)發(fā)技術(shù)
Having a single entry point to a website. Bad? Good? Non-issue?(有一個(gè)網(wǎng)站的單一入口點(diǎn).壞的?好的?沒(méi)問(wèn)題?)
Is MVC + Service Layer common in zend or PHP?(MVC + 服務(wù)層在 Zend 或 PHP 中常見(jiàn)嗎?)
Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)
主站蜘蛛池模板: 国产一区二区在线免费播放 | 日本精品久久 | 中文字幕欧美在线观看 | 日韩精品中文字幕一区二区三区 | 亚洲一区二区三区在线播放 | 国产精品美女久久久久 | 欧美日韩在线看 | 国产日韩精品一区二区 | 国产精品美女久久久久aⅴ国产馆 | 欧美成人一区二区 | 欧美日韩中文字幕在线 | 国产精品一区二区三区四区五区 | 伊人狠狠干 | 国产在线观看网站 | 狠狠爱综合网 | 国产精品久久久久久久毛片 | 精品一二三 | 91成人 | 欧美日韩在线观看一区 | 国产成人精品一区二区三区四区 | 成人在线免费视频 | 国产精品国产三级国产aⅴ浪潮 | 久久精品视频在线播放 | 精品1区2区 | 久久午夜国产精品www忘忧草 | 久久久久久久久久久久91 | 亚洲高清在线 | 女同久久另类99精品国产 | 欧美一区二区三区小说 | 天堂网avav | 日本精a在线观看 | 国产99精品| 亚洲欧美日韩中文字幕一区二区三区 | 久久亚洲国产 | 国产激情视频在线免费观看 | 亚洲国产欧美国产综合一区 | 亚洲伦理自拍 | 成人国产精品久久 | 亚洲国产aⅴ精品一区二区 免费观看av | 在线观看的av | 丁香色婷婷 |