mini3 icon indicating copy to clipboard operation
mini3 copied to clipboard

How to share function across all views

Open hollow6 opened this issue 2 years ago • 4 comments

I'm just getting into using Mini3 MVC framework but am struggling with the concept of where to code a function that is to be used by ALL views. Can anyone help me? Thanks in advance

hollow6 avatar Nov 30 '23 11:11 hollow6

That's probably a question for yourself and how you want to structure your code.

You probably could create a function under the view folder - for example globals, and create functions there, like:

<?php 
// file: application/view/globals/do_something.php

namespace Mini\view\globals;

do_something() { ... }

And in your view-files you could use your function like this: Mini\view\globals\do_something();

But you could put the function basically anywhere in the application folder.

There is not really a 'right' or 'wrong' predefined by Mini3 here.

ebitkov avatar Dec 01 '23 08:12 ebitkov

That's probably a question for yourself and how you want to structure your code.

You probably could create a function under the view folder - for example globals, and create functions there, like:

<?php 
// file: application/view/globals/do_something.php

namespace Mini\view\globals;

do_something() { ... }

And in your view-files you could use your function like this: Mini\view\globals\do_something();

But you could put the function basically anywhere in the application folder.

There is not really a 'right' or 'wrong' predefined by Mini3 here.

I will do that. Thank you for your guidance

hollow6 avatar Dec 01 '23 12:12 hollow6

@hollow6 @panique can we close this one?

crystlbrd avatar Feb 06 '24 11:02 crystlbrd

@hollow6 @panique can we close this one?

Yes thanks

hollow6 avatar Feb 06 '24 12:02 hollow6