I am deciding on a framework to try out for PHP. I have narrowed it down to CakePHP and CodeIgniter. I have a couple of questions for any of you who have used or are familiar with both:
我正在决定试用PHP的框架。我把它缩小到CakePHP和CodeIgniter。对于使用过或熟悉过这两者的人,我有几个问题:
-
I like the fact that CakePHP keeps most of the code outside of the webroot by default. Especially since I may end up using a single framework install for multiple apps. I see CodeIgniter will do that too, but you have to configure it and move some stuff around. Is that workaround secure and reliable, or is it an afterthought hack?
我喜欢CakePHP默认情况下将大部分代码保留在webroot之外的事实。特别是因为我最终可能会为多个应用程序使用单个框架安装。我看到CodeIgniter也会这样做,但你必须配置它并移动一些东西。这种解决方法是安全可靠的,还是后来的黑客入侵?
-
Which (if not both) is easier to upgrade, and maintain over the long term? As new versions of the framework (and PHP itself) come out. I don't want to find my stuff either breaking, or becoming outdated.
哪个(如果不是两个)更容易升级,并且长期维护?随着框架(和PHP本身)的新版本问世。我不想找到我的东西要么破坏,要么变得过时。
Edit:
This is a very old post, but I thought I would update it with what I finally ended up doing, which was to use Kohana.
这是一个非常古老的帖子,但我想我会用我最终做的更新它,这是使用Kohana。
7 个解决方案
#1
4
You should try both frameworks for a week or so, building something trivial (like a blog or wiki) in both, and see which you prefer using. Whatever makes the most sense to you will probably sustain you the longest through upgrades an deprecations.
您应该尝试两个框架一个星期左右,在两者中构建一些微不足道的东西(如博客或维基),并查看您更喜欢使用哪些框架。无论什么对你最有意义,通过升级折旧可能会让你持续时间最长。
CakePHP is in a bit of a volatile state right now, still unearthing bugs while pushing to release version 1.2 (which is not backward compatible). I wouldn't suggest building a critical application with it if you need something rock solid right now. If you can wait a month or two for things to settle, then it's probably a moot point.
CakePHP现在处于一种易变的状态,在推出版本1.2(不向后兼容)的同时仍然发现错误。如果你现在需要一些坚如磐石的东西,我不建议用它构建一个关键的应用程序。如果你可以等待一两个月来解决问题,那么这可能是一个没有实际意义的问题。
To address your concerns:
为了解决您的问题:
1) Cake and CI do it the same way (iirc). They are equally secure, reliable, and hackish on this front.
1)蛋糕和CI以同样的方式(iirc)。他们在这方面同样安全,可靠和狡猾。
2) Everything changes. If you need concrete, perpetual assurance of stability and backward compatibility, roll your own framework. There's not that much to it, and you're guaranteed that nothing changes unless you want it to.
2)一切都在变化。如果您需要具体,永久保证稳定性和向后兼容性,请滚动您自己的框架。没有那么多,除非你想要,否则你保证没有任何改变。
#2
2
I have deployed multiple applications on CakePHP and it's been a very, very, nice experience. You can't go wrong either way, as both are solid.
我在CakePHP上部署了多个应用程序,这是一次非常非常好的体验。不管怎么说都不会出错,因为两者都很稳固。
#3
1
-
is a non-issue.
不是问题。
-
CodeIgniter has a sponsor behind it, so it's definately the one to choose for the long term. Also, it's faster.
CodeIgniter背后有赞助商,所以它绝对是长期选择的赞助商。而且,它更快。
#4
0
-
This is a non issue. The app has a couple of lines which says where the core and your application code lies. You just need to change those lines.
这不是问题。该应用程序有几行代表核心和应用程序代码所在的位置。你只需要改变那些线。
-
You can never anticipate this one.
你永远不能期待这一个。
The state of PHP is a wildcard here. One app (CI) is built to be compatible with PHP4 the other requires PHP5. If you need to deal with the possibilty of a web host only supporting older versions of PHP then you need to go with CO.
PHP的状态是一个通配符。一个应用程序(CI)构建为与PHP4兼容,另一个需要PHP5。如果您需要处理仅支持旧版PHP的Web主机的可能性,那么您需要使用CO。
Another issue is unit testing. If you require your framework to ship with tests, then CI is not the way to go.
另一个问题是单元测试。如果您需要使用您的框架进行测试,那么CI就不是可行的方法。
Personally, I feel comfortable with CI because of the corporate backing. The company behind CI is making real profit from their efforts. Though CI is free, their paid product (ExpressionEngine) will eventually live on CI. The same could be said of the Zend Framework and even the birth of Rails (originally built for Basecamp.)
就个人而言,由于公司支持,我对CI感到满意。 CI背后的公司正在通过他们的努力获得真正的利润。虽然CI是免费的,但他们的付费产品(ExpressionEngine)最终将继续使用CI。 Zend框架甚至Rails的诞生(最初是为Basecamp而建)也是如此。
#5
0
A minor correction to an above comment: both are compatible with PHP4, not just CI. Also, I don't think that having a sponsor makes CI and more or less upgradable or maintainable. Money doesn't solve those problems in the least.
对上述评论的一个小修正:两者都与PHP4兼容,而不仅仅是CI。此外,我不认为拥有赞助商会使CI或多或少可升级或可维护。金钱至少无法解决这些问题。
I use CakePHP for a variety of applications and I've been happy with it thus far. 1.2 is a huge improvement over 1.1, and while the library source may change from RC3 to Final, I don't think any code you write will become obsolete. My only niggle is that the Manual isn't as comprehensive as it should be (in my opinion), and I end up in the API quite a bit. The trade-off there is that I now understand the code behind the scenes very well. In any case, I highly recommend it.
我将CakePHP用于各种应用程序,到目前为止我对此感到满意。 1.2是对1.1的巨大改进,虽然库源可能会从RC3更改为Final,但我认为您编写的任何代码都不会过时。我唯一的问题是手册不是那么全面(在我看来),我最终在API中得到了很多。权衡的是,我现在非常了解幕后的代码。无论如何,我强烈推荐它。
On the other hand, I've never played around with CI, so I can't recommend CakePHP over CI. I would take each for a spin and see which one grabs you. Whichever one you choose, study the hell out of its conventions and capabilities. When I started with Cake, I unwittingly wrote a bunch of code to do something Cake did "automagically" by having me set one variable in the controller.
另一方面,我从未玩过CI,因此我不推荐使用CakePHP而不是CI。我会把每一个旋转,看看哪一个抓住你。无论你选择哪一个,都要研究它的惯例和能力。当我开始使用Cake时,我不知不觉地写了一堆代码来做一些事情,通过让我在控制器中设置一个变量来“自动化”。
#6
0
CodeIgniter is very flexible as you would see once you try it. So how your application would be maintainable would fall you your hands.
CodeIgniter非常灵活,您可以在尝试后看到它。那么你的应用程序如何可维护将落在你的手上。
I have also deployed multiple applications using the same installation. I usually create 2 applications for CMS projects (one for admin, one for the front-end).
我还使用相同的安装部署了多个应用程序。我通常为CMS项目创建2个应用程序(一个用于管理员,一个用于前端)。
#7
0
To address both of your questions from a CodeIgniter perspective (I don't use Cake):
从CodeIgniter透视图解决您的两个问题(我不使用Cake):
1) CodeIgniter doesn't keep itself outside the webroot by default, but it can do so with some very simple changes. The first part of my CI tutorial series explains how to do so, along with a walk through of the setup of a new CI instance. Once finished the only part of CI that needs to be in the webroot is a small index.php bootstrap file.
1)CodeIgniter默认情况下不会将自己保留在webroot之外,但它可以通过一些非常简单的更改来实现。我的CI教程系列的第一部分解释了如何执行此操作,并逐步介绍了新CI实例的设置。完成后,需要在webroot中的唯一CI部分是一个小的index.php引导程序文件。
2) I've got an application which I originally developed in CI 1.4.x and I've sucessfully migrated to 1.5.x then 1.6.x. With each new release the CI dev's make available detailed upgrade instructions laying out what needs to be replaced so upgrades are fairly easy.
2)我有一个我最初在CI 1.4.x中开发的应用程序,我已成功迁移到1.5.x然后1.6.x.每个新版本的CI开发人员都会提供详细的升级说明,列出需要更换的内容,因此升级非常简单。
Jim.
#1
4
You should try both frameworks for a week or so, building something trivial (like a blog or wiki) in both, and see which you prefer using. Whatever makes the most sense to you will probably sustain you the longest through upgrades an deprecations.
您应该尝试两个框架一个星期左右,在两者中构建一些微不足道的东西(如博客或维基),并查看您更喜欢使用哪些框架。无论什么对你最有意义,通过升级折旧可能会让你持续时间最长。
CakePHP is in a bit of a volatile state right now, still unearthing bugs while pushing to release version 1.2 (which is not backward compatible). I wouldn't suggest building a critical application with it if you need something rock solid right now. If you can wait a month or two for things to settle, then it's probably a moot point.
CakePHP现在处于一种易变的状态,在推出版本1.2(不向后兼容)的同时仍然发现错误。如果你现在需要一些坚如磐石的东西,我不建议用它构建一个关键的应用程序。如果你可以等待一两个月来解决问题,那么这可能是一个没有实际意义的问题。
To address your concerns:
为了解决您的问题:
1) Cake and CI do it the same way (iirc). They are equally secure, reliable, and hackish on this front.
1)蛋糕和CI以同样的方式(iirc)。他们在这方面同样安全,可靠和狡猾。
2) Everything changes. If you need concrete, perpetual assurance of stability and backward compatibility, roll your own framework. There's not that much to it, and you're guaranteed that nothing changes unless you want it to.
2)一切都在变化。如果您需要具体,永久保证稳定性和向后兼容性,请滚动您自己的框架。没有那么多,除非你想要,否则你保证没有任何改变。
#2
2
I have deployed multiple applications on CakePHP and it's been a very, very, nice experience. You can't go wrong either way, as both are solid.
我在CakePHP上部署了多个应用程序,这是一次非常非常好的体验。不管怎么说都不会出错,因为两者都很稳固。
#3
1
-
is a non-issue.
不是问题。
-
CodeIgniter has a sponsor behind it, so it's definately the one to choose for the long term. Also, it's faster.
CodeIgniter背后有赞助商,所以它绝对是长期选择的赞助商。而且,它更快。
#4
0
-
This is a non issue. The app has a couple of lines which says where the core and your application code lies. You just need to change those lines.
这不是问题。该应用程序有几行代表核心和应用程序代码所在的位置。你只需要改变那些线。
-
You can never anticipate this one.
你永远不能期待这一个。
The state of PHP is a wildcard here. One app (CI) is built to be compatible with PHP4 the other requires PHP5. If you need to deal with the possibilty of a web host only supporting older versions of PHP then you need to go with CO.
PHP的状态是一个通配符。一个应用程序(CI)构建为与PHP4兼容,另一个需要PHP5。如果您需要处理仅支持旧版PHP的Web主机的可能性,那么您需要使用CO。
Another issue is unit testing. If you require your framework to ship with tests, then CI is not the way to go.
另一个问题是单元测试。如果您需要使用您的框架进行测试,那么CI就不是可行的方法。
Personally, I feel comfortable with CI because of the corporate backing. The company behind CI is making real profit from their efforts. Though CI is free, their paid product (ExpressionEngine) will eventually live on CI. The same could be said of the Zend Framework and even the birth of Rails (originally built for Basecamp.)
就个人而言,由于公司支持,我对CI感到满意。 CI背后的公司正在通过他们的努力获得真正的利润。虽然CI是免费的,但他们的付费产品(ExpressionEngine)最终将继续使用CI。 Zend框架甚至Rails的诞生(最初是为Basecamp而建)也是如此。
#5
0
A minor correction to an above comment: both are compatible with PHP4, not just CI. Also, I don't think that having a sponsor makes CI and more or less upgradable or maintainable. Money doesn't solve those problems in the least.
对上述评论的一个小修正:两者都与PHP4兼容,而不仅仅是CI。此外,我不认为拥有赞助商会使CI或多或少可升级或可维护。金钱至少无法解决这些问题。
I use CakePHP for a variety of applications and I've been happy with it thus far. 1.2 is a huge improvement over 1.1, and while the library source may change from RC3 to Final, I don't think any code you write will become obsolete. My only niggle is that the Manual isn't as comprehensive as it should be (in my opinion), and I end up in the API quite a bit. The trade-off there is that I now understand the code behind the scenes very well. In any case, I highly recommend it.
我将CakePHP用于各种应用程序,到目前为止我对此感到满意。 1.2是对1.1的巨大改进,虽然库源可能会从RC3更改为Final,但我认为您编写的任何代码都不会过时。我唯一的问题是手册不是那么全面(在我看来),我最终在API中得到了很多。权衡的是,我现在非常了解幕后的代码。无论如何,我强烈推荐它。
On the other hand, I've never played around with CI, so I can't recommend CakePHP over CI. I would take each for a spin and see which one grabs you. Whichever one you choose, study the hell out of its conventions and capabilities. When I started with Cake, I unwittingly wrote a bunch of code to do something Cake did "automagically" by having me set one variable in the controller.
另一方面,我从未玩过CI,因此我不推荐使用CakePHP而不是CI。我会把每一个旋转,看看哪一个抓住你。无论你选择哪一个,都要研究它的惯例和能力。当我开始使用Cake时,我不知不觉地写了一堆代码来做一些事情,通过让我在控制器中设置一个变量来“自动化”。
#6
0
CodeIgniter is very flexible as you would see once you try it. So how your application would be maintainable would fall you your hands.
CodeIgniter非常灵活,您可以在尝试后看到它。那么你的应用程序如何可维护将落在你的手上。
I have also deployed multiple applications using the same installation. I usually create 2 applications for CMS projects (one for admin, one for the front-end).
我还使用相同的安装部署了多个应用程序。我通常为CMS项目创建2个应用程序(一个用于管理员,一个用于前端)。
#7
0
To address both of your questions from a CodeIgniter perspective (I don't use Cake):
从CodeIgniter透视图解决您的两个问题(我不使用Cake):
1) CodeIgniter doesn't keep itself outside the webroot by default, but it can do so with some very simple changes. The first part of my CI tutorial series explains how to do so, along with a walk through of the setup of a new CI instance. Once finished the only part of CI that needs to be in the webroot is a small index.php bootstrap file.
1)CodeIgniter默认情况下不会将自己保留在webroot之外,但它可以通过一些非常简单的更改来实现。我的CI教程系列的第一部分解释了如何执行此操作,并逐步介绍了新CI实例的设置。完成后,需要在webroot中的唯一CI部分是一个小的index.php引导程序文件。
2) I've got an application which I originally developed in CI 1.4.x and I've sucessfully migrated to 1.5.x then 1.6.x. With each new release the CI dev's make available detailed upgrade instructions laying out what needs to be replaced so upgrades are fairly easy.
2)我有一个我最初在CI 1.4.x中开发的应用程序,我已成功迁移到1.5.x然后1.6.x.每个新版本的CI开发人员都会提供详细的升级说明,列出需要更换的内容,因此升级非常简单。
Jim.