Support the ongoing development of Laravel.io →
Packages Architecture

Hi, I'm building an app which consistently uses the curl function but with some slight tweaks to variables in the curl function. I don't want to have to create a curl call in every controller I build.

I've poked around and found a few bits about using a custom helper class which seems like it would work. Or I could create my own package which also seems like it could work but potentially overkill in my case.

I just want to check what is best practice for creating a class/function that I'll call from many controllers?

Last updated 3 years ago.
0

You can create a static class in a folder like libraries in your app folder and add it to autoload, then you should be able to call it

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Rossifer rossifer Joined 19 Nov 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.