Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
config_path function for Lumen framework
<?php
if ( ! function_exists('config_path'))
{
/**
* Get the configuration path.
*
* @param string $path
* @return string
*/
function config_path($path = '')
{
return app()->basePath() . '/config' . ($path ? '/' . $path : $path);
}
}

Instructions

Create a file called helpers.php in the app/ directory. Paste the code inside it.

Go to composer.json and add files to autoload so that it looks like this:

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

Run composer dump-autoload to load the newly created helpers file.

@andre-bahia
Copy link

andre-bahia commented May 21, 2018

Thank you man, it's works

@shift14wx
Copy link

shift14wx commented Aug 17, 2020

Thanks a lot!.

@gabriel-silveira
Copy link

gabriel-silveira commented Sep 7, 2020

Another way to fix it, use LumenServiceProvider instead:

$app->register(Tymon\JWTAuth\Providers\LumenServiceProvider::class);

Thank you! This solved my problem!

@rakeshksrandom
Copy link

rakeshksrandom commented Jan 19, 2021

it's working for me composer dump-autoload don't forget to run this commend

Migrating: 2017_11_04_103444_create_laravel_logger_activity_table
Migrated: 2017_11_04_103444_create_laravel_logger_activity_table (1.13 seconds)

@mohsenmojadam2019
Copy link

mohsenmojadam2019 commented Sep 16, 2021

public static function config()
{
if (!function_exists('config_path')) {
function config_path($path = '')
{
return app()->basePath() . '/config' . ($path ? '/' . $path : $path);
}
}
}

@alekaka
Copy link

alekaka commented Feb 18, 2022

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment