If I would like to make a function in Laravel, that is available everywhere in my app, how would I go about that?
What I mean, is that, if I create a function called resizeimage() and would like to call it from anywhere in my Laravel application, how can I do this?
Create a folder named:
libraries
Create a file(class) in your library:
Image.php
Then add this code to
Image.php
:Edit
global.php
in your 'start'-folder: Addapp_path().'/libraries',
Example:
Now you can call your 'function' like this 'anywhere':
You could create a helpers.php file inside app and require it on app/start/global.php.
app/helpers.php
app/start/global.php