where to place other class files??

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

where to place other class files??

cookxyz@gmail.com

I have some "other" class files that I would like to be available to
all of my controllers. These classes are not models, views or
controllers.

Currently, I have made another folder in my app directory and I have
put the includes inside my AppController. This seems to work fine, I'm
just wondering if cake has something like the "$uses" array for other
class files.

Thanks


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: where to place other class files??

fr33dom

morning mate,

I think Vendors is what you're after.

Have a bit of a search around the usual places for Vendors and
there'll be simple explanations on how to go about using the
functionality. Makes things very simple.

Cheers,
Mike

On 06/11/06, [hidden email] <[hidden email]> wrote:

>
> I have some "other" class files that I would like to be available to
> all of my controllers. These classes are not models, views or
> controllers.
>
> Currently, I have made another folder in my app directory and I have
> put the includes inside my AppController. This seems to work fine, I'm
> just wondering if cake has something like the "$uses" array for other
> class files.
>
> Thanks
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: where to place other class files??

Grant Cox

Or even as a Component.  I guess it depends whether these classes are
external, mostly independent projects (common libraries for example) -
which should be in vendors, or whether they are application code, but
need to be shared between controllers - which should be in components.


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: where to place other class files??

cookxyz@gmail.com

Thank you for your suggestions.

 I don't think components would be wise since cake searches that folder
looking for components.

I didn't think vendors was the right place, because they are in fact
specific to each project, not general libraries.

However, I just realized that I was using the cake/vendors folder.
There is also a cake/app/vendors folder which seems more appropriate.
Not the best, perhaps there should be a lib folder inside the app
directory. Or maby I making a big deal out of nothing!


Thanks,
sc


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: where to place other class files??

Mariano Iglesias
In reply to this post by Grant Cox

mm... Shouldn't cake components be in components, and not just any
other PHP class?

I agree with Mikee, vendors is the usual place... But if you don't want
to put them there you could just create a new path under app (called it
libs/ or whatever) and then make sure you include this path on the
include_path on your bootstrap.php file.


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: where to place other class files??

Mariano Iglesias
In reply to this post by cookxyz@gmail.com

app/vendors is for me a path to include all external libraries produced
by third party. For example, that's where I hold the PEAR directory
that includes all pear packages I use.

app/controllers/components should only hold cake valid components. This
is a good place to create a component that would provide a wrapper for
your internal classes, so from your cake controllers you don't call
directly to internal PHP classes, but to cake components that would
handle the more technical details.

by /cake/vendors I'm assuming you are referring to /vendors (not within
cake subdirectory, but within cake's core path). Those should be third
party tools that could be used in MORE than one cake php project.

If I were you I would add a app/libs path, then on your
app/config/bootstrap.php include what you deem adequate from this path.

Also check this other post on this group:
http://groups.google.com/group/cake-php/browse_thread/thread/6f666788e1a0e673/df035d2bb4a92b6c?lnk=gst&q=vendors&rnum=9#df035d2bb4a92b6c


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: where to place other class files??

Mariano Iglesias

I forgot to mention something regarding adding your own libs path.
That's one of the greatest things about CakePHP: how flexible and
scalable it is without having to go and modify the core code as how
it's needed on many other projects.


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: where to place other class files??

cookxyz@gmail.com

Thank you mariano. The boot strap file is exactly what I needed!


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: where to place other class files??

Grant Cox
In reply to this post by Mariano Iglesias

I mistook the OPs meaning in my earlier post.  Certainly, the only
classes in the app/controllers/components folder should be Cake
components.  I thought by "other classes" the OP may mean they just
wanted other application classes, which did not relate to models nor
should be accessible from the views.  The sort of thing you would use a
component for :)


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---