BernardoBF4's avatar

Where to store objects

Where I am supposed to save classes that are not Controllers, Requests, Services, Models, etc, in the app folder of Laravel? The class I want to write is simply an Image classe that will have it's properties and mothod (like save or resize) to be used inside Services.

0 likes
5 replies
tykus's avatar

Nothing to prevent you putting such class(es) in the root of the app directory until the "right" namespace occurs to you.

BernardoBF4's avatar

@tykus I did thought of that but it seems weird to have Classes and then a bunch other classes that are separated in other specific folders depending on their function, and maybe that's the problem: these classes will be "holders" for actual objects and won't have a specific function. They would be like models, but wouldn't have any relations with the database, but no name is coming to mind when thinking of that.

tykus's avatar

@BernardoBF4 is it really that weird... isn't this how frameworks work?

it seems weird to have Classes and then a bunch other classes that are separated in other specific folders depending on their function

no name is coming to mind when thinking of that

you always can refactor easily whenever that becomes apparent 😉

1 like
BernardoBF4's avatar

@tykus Hmmmm, you're starting to make it reasonable to me. Maybe that's a good idea. I plan touse TDD, so refactoring and changing names shouldn't worry me much now

tykus's avatar
tykus
Best Answer
Level 104

@BernardoBF4 a decent IDE will make it trivial to move a class to a different namespace (and directory) while updating all references to that class. A good suite of tests is excellent insurance!

1 like

Please or to participate in this conversation.