userfrosting

Userfrosting best practice for helper functions


What would be the best practice to have custom code (library of functions) in a project using userfrosting?

As of now, I modify existing userfrosting controllers, which bloats the nice concise code.

I guess there is a nice way to keep custom functions in a place, which will not interfere with Userfrosting's code and thereby not be affected much during userfrosting upgrades.

At the moment, i'd like to have some custom functions for notifications, barcode etc.

Guess using a vendor folder under composer would be ideal? If so, how to go about it?

Does userfrosting have any extensibility like symfony?

Any help / pointer is appreciated!

Thanks!


Solution

  • As of version 0.3.1, there is no clean way to separate the core shipped code from developer-implemented code. For minor updates within a version (so, hotfixes to 0.3.1), the best way to keep up-to-date is by using git to make your project a fork of the UserFrosting repository.

    So for example, you might have spurgeon/brood-crm (your project repo) as a fork of userfrosting/UserFrosting. You can then set userfrosting/UserFrosting as an upstream remote for your repo. Whenever a hotfix is released for userfrosting/UserFrosting, you can sync your fork with the upstream. This will pull changes to the main repo into your project, and give you a chance to resolve any merge conflicts (hopefully, there won't be any).

    For people who are not familiar with the distinction between git and GitHub, I should point out that you can do all of this locally, without publishing your fork on GitHub.

    UserFrosting 4 will (finally) have a modular, fully extendable design. Rather than having to directly modify the shipped code, you will be able to override the core routes, templates, schema, assets, etc in a separate directory. Upgrading from version 0.3.x to version 4, however, will probably need to be done manually.