CakePHP - 在我的应用程序结构中放置自定义实用程序类的最佳位置在哪里? [英] CakePHP - Where is the best place to put custom utility classes in my app structure?

查看:190
本文介绍了CakePHP - 在我的应用程序结构中放置自定义实用程序类的最佳位置在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的实用程序类将提供一般的方法来帮助操作字符串。我也可能想要一个数组,数学函数等等。这些应该是组件吗?供应商?

I am making utility classes that will provide general methods for helping manipulate strings. I may also want one for arrays, math functions, etc. Should these be components? Vendors? Could I maybe make these into some sort of vendor package?

推荐答案

如果他们是一般的独立库,没有绑定到任何特定的步骤的请求周期(控制器,模型,视图),将它们放在 app / libs / 中。您可以使用 App :: import('Lib','Foo')来导入它们。

If they're general standalone libraries not tied to any particular step of the request cycle (controller, model, view), put them in app/libs/. You can import them using App::import('Lib', 'Foo').

两个或三个手动数组函数我总是使用在 bootstrap.php 中定义,这是另一个地方放置全局的东西。

Personally I have two or three handy array functions I always use defined in bootstrap.php, which is another place to put a small amount of global stuff.

这篇关于CakePHP - 在我的应用程序结构中放置自定义实用程序类的最佳位置在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆