Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moceanapi/symfony-mocean-bundle
Mocean API for Symfony Framework
https://github.com/moceanapi/symfony-mocean-bundle
mocean moceanapi sms symfony
Last synced: about 1 month ago
JSON representation
Mocean API for Symfony Framework
- Host: GitHub
- URL: https://github.com/moceanapi/symfony-mocean-bundle
- Owner: MoceanAPI
- License: mit
- Created: 2018-12-14T07:15:36.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-29T19:58:34.000Z (over 3 years ago)
- Last Synced: 2024-11-24T16:07:19.380Z (about 2 months ago)
- Topics: mocean, moceanapi, sms, symfony
- Language: PHP
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Symfony Mocean
===============
[![Latest Stable Version](https://img.shields.io/packagist/v/mocean/symfony-mocean-bundle.svg)](https://packagist.org/packages/mocean/symfony-mocean-bundle)
[![Build Status](https://img.shields.io/travis/com/MoceanAPI/symfony-mocean-bundle.svg)](https://travis-ci.com/MoceanAPI/symfony-mocean-bundle)
[![StyleCI](https://github.styleci.io/repos/161746585/shield?branch=master)](https://github.styleci.io/repos/161746585)
[![License](https://img.shields.io/packagist/l/mocean/symfony-mocean-bundle.svg)](https://packagist.org/packages/mocean/symfony-mocean-bundle)
[![Total Downloads](https://img.shields.io/packagist/dt/mocean/symfony-mocean-bundle.svg)](https://packagist.org/packages/mocean/symfony-mocean-bundle)Symfony Mocean API Integration
## Installation
To install the library, run this command in terminal:
```bash
composer require mocean/symfony-mocean-bundle
```Add this to config.yml
```yaml
mocean:
defaults: main # define the account to use here
accounts: # here is where you define multiple accounts
main:
api_key: mainAccountApiKey
api_secret: mainAccountApiSecret
secondary:
api_key: secondaryAccountApiKey
api_secret: secondaryAccountApiSecret
```### Symfony 4
Add the bundle to `config/bundles.php`
```php
return [
//... framework bundles
MoceanSymBundle\MoceanBundle::class => ['all' => true],
];
```### Symfony 3
Add the bundle to `app/AppKernel.php`
```php
$bundles = array(
//... framework bundles
new MoceanSymBundle\MoceanBundle(),
);
```## Usage
Usage through dependency injection (symfony 4 and above)
Bind mocean manager class in service yaml
```yaml
# config/services.yamlservices:
App\Controller\YourController:
bind:
$mocean: '@mocean_manager'
```Using autowiring
```yaml
# config/services.yamlservices:
MoceanSymBundle\Services\MoceanManager: '@mocean_manager'
```In controller
```php
class YourController extends AbstractController
{
/**
* @Route("/")
*/
public function index(MoceanSymBundle\Services\MoceanManager $mocean)
{
$res = $mocean->message()->send([
'mocean-to' => '60123456789',
'mocean-from' => 'MOCEAN',
'mocean-text' => 'Hello World'
]);
}
}
```Usage through container
```php
class YourController extends Controller
{
/**
* @Route("/")
*/
public function index()
{
$mocean = $this->container->get('mocean_manager');
$res = $mocean->message()->send(...);
}
}
```The above example will be using the account define in defaults.
If you have multiple account defined in config, you can use like this```php
$mocean->using('secondary')->message()->send(...);
$mocean->using('third')->message()->send(...);
```## License
Laravel Mocean is licensed under the [MIT License](LICENSE)