PHP code example of nacosvel / locator

1. Go to this page and download the library: Download nacosvel/locator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nacosvel / locator example snippets


return [
    'default' => 'alipay',
    'alipay'  => [
        'default'          => '2021004102600103',
        '2021004102600102' => [
            'app_id' => '2021004102600102****',
        ],
        '2021004102600103' => [
            'app_id' => '2021004102600103****',
        ],
    ],
    'wechat'  => [
        'mch_id' => '190000****',
    ],
];

use Nacosvel\Locator\Concerns\HasAdapter;
use Nacosvel\Locator\Contracts\Adapter;
use Nacosvel\Locator\MultipleManager;

class Payment implements Adapter
{
    use HasAdapter;

    public function __construct(
        protected string $name,
        protected array $config,
    ) {
        //
    }
}

$config  = etName(),
    $manager->instance('alipay')->getDefaultConfig(),
    $manager->instance('alipay')->getConfig(),
    $manager->instance('wechat')->getName(),
    $manager->instance('wechat')->getDefaultConfig(),
    $manager->instance('wechat')->getConfig(),
);