Skip to content

Commit

Permalink
Hello World
Browse files Browse the repository at this point in the history
  • Loading branch information
yedincisenol committed Aug 9, 2018
0 parents commit 3f375ff
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: php
php:
- '7.0'
- '7.1'
- '7.2'
before_script: composer install
script: phpunit
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

[![Travis](https://img.shields.io/travis/yedincisenol/vision.svg?style=for-the-badge)]()
[![Packagist](https://img.shields.io/packagist/dt/yedincisenol/vision.svg?style=for-the-badge)]()
[![Packagist](https://img.shields.io/packagist/v/yedincisenol/vision.svg?style=for-the-badge)]()
[![Packagist](https://img.shields.io/packagist/l/yedincisenol/vision.svg?style=for-the-badge)]()

Create Firebase Dynamic Links from Php and Laravel

* <a href="#php-config">Configuration</a>
* <a href="#laravel-install"> Laravel Installation</a>
* <a href="#usage">Usage examples</a>

### <a name="laravel-install"></a> Laravel Install

- Add composer
```php
composer require "yedincisenol/vision"
```

- Add service provider (For Laravel 5.6 before)
`config/app.php`

```php
'providers' => [
...
yedincisenol\Vision\LaravelServiceProvider::class
],
```

- Add Facede

`config/app.php`

```php
'aliases' => [
...
'Vision' => \yedincisenol\Vision\LaravelFacede::class
],
```

- Fill Environments
> copy theese parameters to your project .env and fill
```
VISION_CREDENTIALS_PATH=
```

> How to get credentials file? <a href="http://googlecloudplatform.github.io/google-cloud-php/#/docs/google-cloud/v0.73.0/guides/authentication">Visit here</a>
- Laravel Usage
```
use Vision;
image = Vision::image(file_get_contents('https://cdn.britannica.com/700x450/04/1304-004-E64E228C.jpg'), ['LABEL_DETECTION']);
$results = Vision::annotate($image);
collect(Vision::annotate($image)->labels())->each(function ($l) { echo $l->description() . PHP_EOL; });
```

For more detail visit <a href="http://googlecloudplatform.github.io/google-cloud-php/#/docs/cloud-vision/v0.15.2/vision/readme">here</a>

- Publish Config file (Optional)

```$xslt
php artisan vendor:publish --tag=vision
```
38 changes: 38 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "yedincisenol/vision",
"description": "Laravel wrapper for GCloud Vision PHP client",
"type": "library",
"require": {
"google/cloud-vision": "^0.15.2"
},
"license": "MIT",
"authors": [
{
"name": "Ibrahim S. Orencik",
"email": "o@yedincisenol.com"
}
],
"extra": {
"laravel": {
"providers": [
"yedincisenol\\Vision\\LaravelServiceProvider"
]
}
},
"autoload": {
"psr-0" : {
"yedincisenol\\Vision\\" : "src"
},
"psr-4": {
"yedincisenol\\Vision\\" : "src"
}
},
"keywords": [
"gcloud",
"laravel",
"vision",
"gcloud vision",
"php vision"
],
"version": "0.1.0"
}
11 changes: 11 additions & 0 deletions src/LaravelFacede.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace yedincisenol\Vision;

use Illuminate\Support\Facades\Facade;

class LaravelFacede extends Facade {

protected static function getFacadeAccessor() { return Vision::class; }

}
63 changes: 63 additions & 0 deletions src/LaravelServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* Created by PhpStorm.
* User: yedin
* Date: 9.8.2018
* Time: 21:19
*/

namespace yedincisenol\Vision;

use Google\Cloud\Vision\VisionClient;
use Illuminate\Support\ServiceProvider;

class LaravelServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$this->publishes([
__DIR__ . '/config.php' => config_path('vision.php'),
], 'vision');
$this->mergeConfigFrom(
__DIR__ . '/config.php', 'vision'
);
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton(Vision::class, function ($app) {
return new VisionClient([
'keyFilePath' => $app['config']['vision']['credentials_path']
]);
});

$this->app->alias(Vision::class, 'vision');

}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [
'Vision'
];
}
}
10 changes: 10 additions & 0 deletions src/Vision.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace yedincisenol\Vision;

use Google\Cloud\Vision\VisionClient;

class Vision extends VisionClient
{

}
5 changes: 5 additions & 0 deletions src/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'credentials_path' => env('VISION_CREDENTIALS_PATH')
];

0 comments on commit 3f375ff

Please sign in to comment.