suunnn/laravel-rongcloud

RongCloud SDK for Laravel

1.0.0 2021-08-19 06:13 UTC

This package is auto-updated.

Last update: 2024-05-19 12:49:00 UTC


README

Requirements

  • php >= 7.0
  • composer
  • laravel >= 5.1

Installation

$ composer require suunnn/laravel-rongcloud

The Suunnn\LaravelRongcloud\ServiceProvider is auto-discovered and registered by default.

If you want to register it yourself or laravel < 5.5, add the ServiceProvider in config/app.php:

'providers' => [
    /*
     * Package Service Providers...
     */
     Suunnn\LaravelRongcloud\ServiceProvider::class,
],

The RongCloud facade is also auto-discovered.

If you want to add it manually or laravel < 5.5, add the Facade in config/app.php:

'aliases' => [
    ...
    'RongCloud' => Suunnn\LaravelRongcloud\Facades\RongCloud::class,
],

Configuration

To publish the config, run the vendor publish command:

$ php artisan vendor:publish --provider="Suunnn\LaravelRongcloud\ServiceProvider" --tag=laravel-rongcloud

config/rongcloud.php:

return [
    'app_key' => 'your app key',
    'app_secret' => 'your app secret'
];

Usage

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use RongCloud;
use Illuminate\Routing\Controller;

class UserController extends Controller
{
    public function store(Request $request)
    {
        $user = [
            'id' => 'USER01',
            'name' => 'PHPSDK', //用户名称
            'portrait' => '' //用户头像
        ];

        $token = RongCloud::getUser()->register($user);
    }
}

Documentation

License

MIT