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

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

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

問題描述

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

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...

該框架既供我自己使用,又可進一步提高我的 PHP 技能.我遇到了許多問題,通過克服它們,我學到了很多東西,并且喜歡能夠從無到有創(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)在該往哪個方向發(fā)展!無法完全理解這一切...

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 是主文件,每個請求都通過 .htaccess 路由到這里.
  • private/ 顯然不能公開訪問.
  • public/ 包含所有公共文件.
  • app/ 包含所有特定于應用的代碼.
  • lib/ 可以包含 Zend 或其他庫(我也在自己開發(fā)),以使用自動加載器調(diào)用
  • bootstrap.php 是特定于應用程序的代碼... 我需要這個嗎?主要的'index.php'就夠了嗎?.
  • modules/ 將包含每個模塊... 我需要模塊嗎?.
  • default/ 是包含大多數(shù)請求的 MVC 的默認模塊(當admin"不是 URL 的第一部分時使用).
  • 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ǎng)站的其余部分分開會更好,但這就是我陷入困境的地方.我已經(jīng)制作了上述結(jié)構(gòu)來使用它,但我不確定這是否是最有效的方法.

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.

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

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

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

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

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

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

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

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

這是解決這個問題的正確方法嗎?或者我是否過度復雜化并做了一些不值得做的事情?

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

我的管理部分是否應該有一個完全獨立的應用程序框架...?我什至需要將管理部分的 MVC 與其他部分分開嗎?

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?

抱歉問了這么大的問題,只是想為您提供盡可能多的信息!隨意回答你能回答的部分=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

推薦答案

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

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)對此進行概括看看你最喜歡的框架是怎么做的

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

另外一點

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

希望能幫到你

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

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

相關(guān)文檔推薦

Action View Helper in Zend - Work around?(Zend 中的動作視圖助手 - 解決方法?)
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 中的部分(視圖),以便我的應用程序中的所有視圖都可以訪問?) - IT屋-程序員軟件開發(fā)技術(shù)
Having a single entry point to a website. Bad? Good? Non-issue?(有一個網(wǎng)站的單一入口點.壞的?好的?沒問題?)
Is MVC + Service Layer common in zend or PHP?(MVC + 服務層在 Zend 或 PHP 中常見嗎?)
Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)
主站蜘蛛池模板: 国产成人免费视频 | 国产日韩欧美二区 | 曰批视频在线观看 | 7799精品视频天天看 | 欧美久久精品一级黑人c片 91免费在线视频 | 国产一区二区麻豆 | 欧美福利专区 | 亚洲一卡二卡 | 一区二区视频 | 国产福利91精品 | 欧美成人h版在线观看 | 中文字幕av网址 | 日韩午夜 | 欧美在线观看一区二区 | 欧美日韩国产中文 | 欧美天堂 | 中文字幕久久久 | 日韩免费高清视频 | 美女在线观看av | 精品日韩在线 | 精品毛片| 久久小视频 | 国产一区二区三区免费 | 亚洲综合色视频在线观看 | 国产精品中文字幕一区二区三区 | 狠狠草视频 | 日本中文在线视频 | 国产精品a免费一区久久电影 | 国产一级片在线播放 | 99在线视频观看 | 五月激情婷婷在线 | 国产成人99久久亚洲综合精品 | 亚洲福利在线观看 | 久久国产亚洲 | 日韩精品一二三区 | 99久久精品国产一区二区三区 | 国产精品免费一区二区三区四区 | 亚洲精品一区二区另类图片 | 亚洲免费在线播放 | 在线看成人av | 精品美女在线观看 |