-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3f375ff
Showing
8 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
return [ | ||
'credentials_path' => env('VISION_CREDENTIALS_PATH') | ||
]; |