Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP - Where is the best place to put custom utility classes in my app structure?

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?

like image 902
BadHorsie Avatar asked Dec 17 '22 09:12

BadHorsie


1 Answers

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.

like image 71
deceze Avatar answered Mar 29 '23 23:03

deceze