Skip to content

Commit

Permalink
Initial skeleton of the package
Browse files Browse the repository at this point in the history
  • Loading branch information
moe-mizrak committed Jan 11, 2025
1 parent 0ddfc0d commit 4e383f4
Show file tree
Hide file tree
Showing 12 changed files with 309 additions and 0 deletions.
Empty file added .github/workflows/main.yml
Empty file.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/vendor/
/.idea
/composer.lock
.phpunit.result.cache
.DS_Store
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# aws-rekognition
Laravel package for AWS Rekognition API (PHP 8)

# 🚧 Under Construction 🚧
55 changes: 55 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "moe-mizrak/aws-rekognition",
"description": "Laravel package for AWS Rekognition API (PHP 8)",
"keywords": [
"Moe Mizrak",
"laravel",
"laravel-aws-rekognition",
"rekognition",
"aws",
"image processing",
"image recognition",
"video recognition",
"face detection",
"face compare",
"machine learning",
"php 8"
],
"type": "package",
"homepage": "https://github.com/moe-mizrak/aws-rekognition",
"license": "MIT",
"authors": [
{
"name": "Moe Mizrak"
}
],
"require": {
"php": "^8.2"
},
"require-dev": {
"orchestra/testbench": "^9.6.1",
"phpunit/phpunit": "^11.4"
},
"autoload": {
"psr-4": {
"MoeMizrak\\Rekognition\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"MoeMizrak\\Rekognition\\Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
"MoeMizrak\\Rekognition\\RekognitionServiceProvider"
]
}
},
"scripts": {
"test": "phpunit"
},
"minimum-stability": "dev",
"prefer-stable": true
}
4 changes: 4 additions & 0 deletions config/aws-rekognition.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

return [
];
11 changes: 11 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<phpunit bootstrap="vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="Application Tests">
<directory>./tests</directory>
</testsuite>
</testsuites>

<php>
<env name="APP_ENV" value="testing"/>
</php>
</phpunit>
21 changes: 21 additions & 0 deletions src/Facades/Rekognition.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace MoeMizrak\Rekognition\Facades;

use Illuminate\Support\Facades\Facade;

/**
* Facade for AWS Rekognition.
*/
class Rekognition extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor(): string
{
return 'aws-rekognition';
}
}
16 changes: 16 additions & 0 deletions src/RekognitionAPI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace MoeMizrak\Rekognition;

/**
* RekognitionAPI abstract class responsible for encapsulating the RekognitionRequest class.
*
* @class Abstract RekognitionAPI
*/
readonly abstract class RekognitionAPI
{
/**
* RekognitionAPI constructor.
*/
public function __construct() {}
}
13 changes: 13 additions & 0 deletions src/RekognitionRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace MoeMizrak\Rekognition;

final readonly class RekognitionRequest extends RekognitionAPI
{
public function test()
{
// todo for testing purposes, remove later

return 'test';
}
}
97 changes: 97 additions & 0 deletions src/RekognitionServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php

namespace MoeMizrak\Rekognition;

use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\ServiceProvider;
use MoeMizrak\Rekognition\Facades\Rekognition;

/**
* Service provider for Rekognition.
*
* @class RekognitionServiceProvider
*/
class RekognitionServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot(): void
{
$this->registerPublishing();
}

/**
* Register any application services.
*
* @return void
*/
public function register(): void
{
$this->configure();

// todo modify this part for aws rekognition request
// $this->app->singleton(ClientInterface::class, function () {
// return $this->configureClient();
// });

$this->app->bind('aws-rekognition', function () {
return new RekognitionRequest();
});

$this->app->bind(RekognitionRequest::class, function () {
return $this->app->make('aws-rekognition');
});

// Register the facade alias.
AliasLoader::getInstance()->alias('Rekognition', Rekognition::class);
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides(): array
{
return ['aws-rekognition'];
}

/**
* Setup the configuration.
*
* @return void
*/
protected function configure(): void
{
$this->mergeConfigFrom(
__DIR__ . '/../config/aws-rekognition.php', 'aws-rekognition'
);
}

/**
* Register the package's publishable resources.
*
* @return void
*/
protected function registerPublishing(): void
{
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__ . '/../config/aws-rekognition.php' => config_path('aws-rekognition.php'),
], 'aws-rekognition');
}
}

/**
* Configure the Guzzle client.
*
* @return \GuzzleHttp\Client
*/
private function configureClient(): Client
{
// todo implement for aws rekognition request
}
}
43 changes: 43 additions & 0 deletions tests/RekognitionRequestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace MoeMizrak\Rekognition\Tests;

use MoeMizrak\Rekognition\Facades\Rekognition;
use MoeMizrak\Rekognition\RekognitionRequest;
use PHPUnit\Framework\Attributes\Test;

class RekognitionRequestTest extends TestCase
{
private RekognitionRequest $rekognition;

public function setUp(): void
{
parent::setUp();

$this->rekognition = $this->app->make(RekognitionRequest::class);
}

#[Test]
public function it_test()
{
/* SETUP */

/* EXECUTE */
$response = $this->rekognition->test();
dd($response);

/* ASSERT */
}

#[Test]
public function it_test_facade()
{
/* SETUP */

/* EXECUTE */
$response = Rekognition::test();
dd($response);

/* ASSERT */
}
}
42 changes: 42 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace MoeMizrak\Rekognition\Tests;

use MoeMizrak\Rekognition\Facades\Rekognition;
use MoeMizrak\Rekognition\RekognitionServiceProvider;
use Orchestra\Testbench\TestCase as OrchestraTestCase;

class TestCase extends OrchestraTestCase
{
/**
* @return void
*/
public function setUp(): void
{
parent::setUp();
}

/**
* @param $app
*
* @return string[]
*/
protected function getPackageProviders($app): array
{
return [
RekognitionServiceProvider::class,
];
}

/**
* @param $app
*
* @return string[]
*/
protected function getPackageAliases($app): array
{
return [
'Rekognition' => Rekognition::class,
];
}
}

0 comments on commit 4e383f4

Please sign in to comment.