简体   繁体   English

如何在CakePHP上创建自己的库

[英]How to create my own library on CakePHP

I am new to cakephp and I managed to work my way out doing some great stuff with this powerful framewoek. 我是Cakephp的新手,我设法通过此强大的framewoek做出了一些很棒的事情。 Seeking some organization in my code, I am looking for a way to create some kind of side library to call it whenever it. 在我的代码中寻找某种组织,我正在寻找一种创建某种边库以在任何时候调用它的方法。

I am working on the mailing layer of my application using the built in mailing utility, so I want to know how to create a library where i can store my functions. 我正在使用内置的邮件实用程序来处理应用程序的邮件层,因此我想知道如何创建一个可以存储函数的库。

Thank you. 谢谢。

you can create your own library file in 您可以在以下位置创建自己的库文件

/app/Lib/Library_Class_name.php /app/Lib/Library_Class_name.php

class Library_Class_name {
   public function function_name() {

   }
}

after this you should need to use load this Library file to your application use below code 在此之后,您需要使用将此库文件加载到您的应用程序中,使用以下代码

App::uses('Library_Class_name', 'Lib'); App :: uses('Library_Class_name','Lib');

One this, If you want to load this file for entire application you need to use above App::uses code to your Config/bootstrap.php file otherwise you can use this to needed files or functions. 其中之一,如果您想为整个应用程序加载此文件,则需要在App :: uses代码上方使用Config / bootstrap.php文件,否则可以将其用于所需的文件或功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM