Wednesday, January 21, 2009

How to define a global function in bootstap.php?

I asked something similar a while back and I believe the preferred way
of including your own functions goes like this.

Put your functions in a file in your "vendors" folder. Either one will
do.
Include your file in bootstrap.php using App::import('Vendor',
'basics');

That is the most Cake-friendly way I know of.

/Martin

On Apr 16, 9:00 am, Sourabh Sharma <sourabh47mca...@gmail.com> wrote:

- Hide quoted text -

- Show quoted text -

> If You want declare the global functions for your application then you
> have create a file in parallel to bootstrap.php like
> commonfunctions.php or if you want to declare the constants for your
> application like constants.php

> Then you have to include the both the files in the bootstap.php  then
> you can use the function with out any constructor in any file of your
> application

> like if you declare a function abc() in the commonfunction and you
> have to declare the commonfunction.php in bootstarp then you have to
> use like this any file abc().

> if you have any confusion so please mail me at
> sourabh47mca...@gmail.com

> Thanks & Regards
> Sourabh Sharma

> On Apr 16, 10:43 am, Freshow <dyh1...@gmail.com> wrote:

> > how to define a global function for all controllers in ./app/confing/
> > bootstap.php ,and how to inplement it in controller ?

> > :)

No comments: