4

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?

Fury
  • 4,643
  • 5
  • 50
  • 80
BadHorsie
  • 14,135
  • 30
  • 117
  • 191
  • http://stackoverflow.com/questions/24261432/how-to-use-common-function-in-helper-and-component-in-cakephp – trante Aug 09 '14 at 21:38
  • http://stackoverflow.com/questions/10768816/where-to-save-a-custom-class-and-how-to-load-it-in-a-cakephp-component – trante Nov 02 '14 at 12:10

1 Answers1

12

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').

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.

deceze
  • 510,633
  • 85
  • 743
  • 889
  • 1
    How would you do this in cakephp3? http://stackoverflow.com/questions/35955881/include-utility-class-all-over-the-application-cakephp-3 – Fury Mar 15 '16 at 06:46