Creating a Helpers File in Laravel 5.3

Helper file in very useful to create custom helper functions in Laravel app. We can use these custom helper functions app-wide.

First create the file  app/helpers.php.

 

Then either load this file in any of the core Laravel file that autoloads when the application starts. Like,

require app_path() . '/helpers.php';

 

OR, change your composer.json file and dump the autoloader.

Example:

"autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        },
        "files": [
            "app/helpers.php"
        ]
    },

 

Then Run: composer dump-auto or composer dump-autoload

Setup Virtual Host with XAMPP in Windows OS

A virtual host can point to any folder on any drive of the system, it’s generally used to easily manage if we store all of our sites in a common location (like HTDOCS folder in case of XAMPP).

Virtual host also enables us to use “Preety URL” in our local development environment. Like:

We can Use: http://laravel.dev
Instead of: http://localhost/laravel5-test/public/

In short, virtual host enables us to point any directory or sub-directory by using our given (i.e. custom) URL format.
Continue reading