0

In my Laravel Project, I want to use Github project having just 1 file. No composer package included. This file have some formulas to calculate the result and have 7 functions.

My Question: Where to save this file in my project?

Or

Can I directly copy those functions in my controller/Model?

Please suggest.

5
  • 1
    Need more clarity what you mean by the question. Commented Mar 20, 2018 at 12:36
  • @Jigs1212 Updated with more details Commented Mar 20, 2018 at 12:50
  • 1
    @SVM why don't you just copy and past in a model ? or use a helper function(not recommend) Commented Mar 20, 2018 at 14:10
  • Thanks @SupunFictionPraneeth , I will copy and paste in model. Just wanted to know the best practice. whether to use in Model or Controller or Helper function. Commented Mar 20, 2018 at 14:30
  • 1
    @SVM using as helper is not recommended because it appear in everywhere in the app so there might be conflict with other functions Commented Mar 20, 2018 at 14:35

1 Answer 1

1

Usually when I include code in laravel that is not part of a composer package I create a folder in the App folder with my nickname or companyname:

/project_folder/app/company/helperfunctions.php

You can still use composer to autoload the file if you want. Just include the classmap in your composer.json and add the path to your folder

"autoload": {
        "classmap": [
            "app/company"
        ],

    },
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.