简体   繁体   中英

Laravel return array value from app/config/package folder

Hi I am using a laravel package https://github.com/greggilbert/recaptcha and I have published the config files where I need to store my public and private keys for my recaptcha. I want to call this elsewhere in my app in an attempt to process this via AJAX . I've tried to call this as

dd(Config::get('packages.greggilbert.recaptcha')['public_key']);

however this returns as null. The array is kept in the following folder:

app/config/packages/greggilbert/recaptcha/config.php

the array is built as so:

<?php

return array(


    'public_key'    => 'publickey',
    'private_key'   => 'privatekey',

    'template'      => '',

    'driver'    => 'curl',

    'options'       => array(

        'curl_timeout' => 1,

    ),

    'version'       => 2,

); 

Any ideas how I can retrieve the public_key value??

Retrieving configs from a package works a bit different. You use a so-called namespace :

Config::get('recaptcha::public_key');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM