简体   繁体   English

Laravel从app / config / package文件夹返回数组值

[英]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. 嗨,我使用的是laravel软件包https://github.com/greggilbert/recaptcha ,我已经发布了配置文件,我需要在其中存储用于我的Recaptcha的公钥和私钥。 I want to call this elsewhere in my app in an attempt to process this via AJAX . 我想在我的应用程序的其他地方调用它,以尝试通过AJAX处理它。 I've tried to call this as 我试图称其为

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

however this returns as null. 但是,此返回为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?? 有什么想法可以检索public_key值吗?

Retrieving configs from a package works a bit different. 从软件包中获取配置的方法有些不同。 You use a so-called namespace : 您使用所谓的名称空间

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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