Monday, April 16, 2012

Re: Where am I supposed to save additional PHP source files while I'm writing a new behavior

Hats off if you are new and already working on behaviors :)

Vendor would be only for third party stuff. since you write your own code there is only one suitable place left for library files:
/APP/Lib
Just store your files there - preferably grouped in packages (e.g. "MyPackageName")

for you it could be sth like
/APP/Lib/MyPackageName/MyBehaviorHelperLib.php
/APP/Lib/MyPackageName/MyOtherBehaviorHelperLib.php

and then you can use your new MyBehaviorHelperLib class by defining it at the top of the behavior

App::uses('MyBehaviorHelperLib', 'MyPackageName');

inside the behavior:

$MyBehaviorHelperLib = new MyBehaviorHelperLib()
$MyBehaviorHelperLib->foo();

or - if it is callable statically:

MyBehaviorHelperLib::foo();




Am Dienstag, 17. April 2012 02:05:09 UTC+2 schrieb Daniel Baird:

Hi Cake dudes,

I'm new to Cake, and I'm adding a behavior to a model.  I've done that by writing a PHP file that I save in the Behavior directory.

Now I'm making that Behavior a bit more complicated, and I'd like to split some sections of code out into separate files.  This Behavior is pretty specific to my application, I can't imagine wanting to make it a redistributable plugin or anything.

So here's my question: where's the recommended place to save those supporting files?  Can I just make a subdir or Behavior and save them all in there?  Or am I supposed to save my additional files into the Vendor dir or something like that.

Thanks in advance

Daniel

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate