我目前正在开发我自己的 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 技能.我遇到了许多问题,通过克服它们,我学到了很多东西,并且喜欢能够从无到有创造一些东西,所以我不想看到像只使用 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"! ;)
我已经阅读了很多关于 Stack Overflow 和其他网站的文章,但不能完全得到我需要的正确答案,所以希望有人能给我一些有用的建议!
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!
我尝试了几种不同的解决方案,但我最终让自己感到困惑,我不确定现在该往哪个方向发展!无法完全理解这一切...
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...
'理论'框架结构
- .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
详情
无论如何,对于我的问题...
我认为将管理部分与网站的其余部分分开会更好,但这就是我陷入困境的地方.我已经制作了上述结构来使用它,但我不确定这是否是最有效的方法.
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/ 来到我的网站..
If a request site.com/videos/view/1/ comes to my site..
模块:默认控制器:视频操作:查看参数:数组('1')
Module: Default Controller: Videos Action: View Params: array( '1' )
如果请求 site.com/admin/pages/view/1/ 来到我的网站..
and if the request site.com/admin/pages/view/1/ comes to my site..
模块:管理员控制器:页面操作:查看参数:数组('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 所做的,您首先为管理字符串定义一个配置然后在您的控制器中使用具有特定命名转换的动作
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/
}
}
您可以使用路由系统对此进行概括看看你最喜欢的框架是怎么做的
You can generalize this by using a routing system just look how your favorite framework does it
另外一点
希望能帮到你
这篇关于PHP MVC 框架的文件夹结构......我这样做对吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!