Skip to content

Instantly share code, notes, and snippets.

@setkyar
Created January 23, 2015 07:29

Revisions

  1. setkyar created this gist Jan 23, 2015.
    29 changes: 29 additions & 0 deletions helper
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    //Create New Folder Call MyClass on `app/` directory

    Add new line on `/app/start/global.php`

    ClassLoader::addDirectories(array(
    app_path().'/commands',
    app_path().'/controllers',
    app_path().'/models',
    app_path().'/database/seeds',
    app_path().'/MyClass', // This line is the one we need to add
    ));

    Create a file in `app/MyClass/Helper.php` and add such as like

    <?php namespace Helpers;

    class Helper {

    public static function helloWorld()
    {
    return 'Hello World';
    }
    }

    All you would need to do is call `Helpers\Helper::helloWorld();`

    You could also **alias** this helper class in your `/app/config/app.php` file. Just add something like this to the end of the aliases array:

    'Helper' => 'Helpers\Helper'