diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml deleted file mode 100644 index 5958175..0000000 --- a/.github/workflows/dependabot-auto-merge.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: "Dependabot auto-merge" - -on: [pull_request_target] # yamllint disable-line rule:truthy - -permissions: - contents: "write" - -jobs: - dependabot: - runs-on: "ubuntu-latest" - if: "${{ github.actor == 'dependabot[bot]' }}" - steps: - - name: "Dependabot metadata" - id: "metadata" - uses: "dependabot/fetch-metadata@v2.2.0" - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - name: "Enable auto-merge for Dependabot PRs" - if: "${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}" - run: "gh pr merge --auto --merge \"$PR_URL\"" - env: - PR_URL: "${{github.event.pull_request.html_url}}" - GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 72f4724..f657e1e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,68 +1,60 @@ name: Tests on: - pull_request: - paths: - - 'config/**' - - 'src/**' - - 'tests/**' - - '.github/workflows/tests.yml' - - 'composer.json' - push: - branches: ['main'] - paths: - - 'config/**' - - 'src/**' - - 'tests/**' - - '.github/workflows/tests.yml' - - 'composer.json' - workflow_dispatch: + push: + pull_request: jobs: - test: - name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - runs-on: 'ubuntu-latest' - - strategy: - matrix: - php: - - "8.1" - - "8.2" - - "8.3" - - "8.4" - laravel: - - "9" - - "10" - - "11" - exclude: - - php: "8.1" - laravel: "11" - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: ctype, dom, grpc, json, mbstring, openssl, xml, zip, zlib - coverage: xdebug - - - name: Install dependencies - run: | - composer require -W "illuminate/contracts:^${{ matrix.laravel }}.0" - composer require -W --dev orchestra/testbench - - - name: Setup Problem Matchers - run: | - echo "::add-matcher::${{ runner.tool_cache }}/php.json" - echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - - name: Run PHPUnit - run: vendor/bin/phpunit --coverage-clover=coverage.xml --log-junit=test-report.xml --testdox - - - name: Upload code coverage - uses: codecov/codecov-action@v5 - with: - token: ${{ secrets.CODECOV_TOKEN }} + test: + runs-on: 'ubuntu-latest' + strategy: + fail-fast: false + matrix: + php: ['7.4'] + laravel: ['6.0', '7.0', '8.0'] + include: + - laravel: '8.0' + testbench: '6.0' + - laravel: '7.0' + testbench: '5.2' + - laravel: '6.0' + testbench: '4.8' + + name: Laravel ${{ matrix.laravel }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: ctype, dom, json, mbstring, openssl, xml, zip, zlib + coverage: xdebug + + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: Install dependencies + run: | + composer require "laravel/framework:^${{ matrix.laravel }}" "orchestra/testbench:^${{ matrix.testbench }}" --no-interaction --no-update + composer update --prefer-dist --no-interaction --no-suggest + + - name: Setup Problem Matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Execute tests + run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml --log-junit=test-report.xml + + - name: Upload code coverage + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/composer.json b/composer.json index 75833cb..07f3df1 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "kreait/laravel-firebase", + "name": "cybrary/laravel-firebase", "description": "A Laravel package for the Firebase PHP Admin SDK", "keywords": ["laravel", "firebase", "firebase", "sdk", "api", "database", "fcm", "gcm"], "type": "library", @@ -38,10 +38,24 @@ "Kreait\\Laravel\\Firebase\\ServiceProvider" ], "aliases": { - "Firebase": "Kreait\\Laravel\\Firebase\\Facades\\Firebase" + "Firebase": "Kreait\\Laravel\\Firebase\\Facades\\Firebase", + "FirebaseAuth": "Kreait\\Laravel\\Firebase\\Facades\\FirebaseAuth", + "FirebaseIdentityPlatform": "Kreait\\Laravel\\Firebase\\Facades\\FirebaseIdentityPlatform", + "FirebaseDatabase": "Kreait\\Laravel\\Firebase\\Facades\\FirebaseDatabase", + "FirebaseDynamicLinks": "Kreait\\Laravel\\Firebase\\Facades\\FirebaseDynamicLinks", + "FirebaseFirestore": "Kreait\\Laravel\\Firebase\\Facades\\FirebaseFirestore", + "FirebaseMessaging": "Kreait\\Laravel\\Firebase\\Facades\\FirebaseMessaging", + "FirebaseRemoteConfig": "Kreait\\Laravel\\Firebase\\Facades\\FirebaseRemoteConfig", + "FirebaseStorage": "Kreait\\Laravel\\Firebase\\Facades\\FirebaseStorage" } } }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/Cybrary/firebase-php" + } + ], "scripts": { "cs": [ "vendor/bin/pint" diff --git a/src/Facades/FirebaseIdentityPlatform.php b/src/Facades/FirebaseIdentityPlatform.php new file mode 100644 index 0000000..39b5e6f --- /dev/null +++ b/src/Facades/FirebaseIdentityPlatform.php @@ -0,0 +1,19 @@ +auth; } + public function identityPlatform(): Firebase\IdentityPlatform + { + if (!$this->identityPlatform) { + $this->identityPlatform = $this->factory->createIdentityPlatform(); + } + + return $this->identityPlatform; + } + + public function database(): Database { if (! $this->database) { diff --git a/src/FirebaseProjectManager.php b/src/FirebaseProjectManager.php index 1b32cf8..bded958 100644 --- a/src/FirebaseProjectManager.php +++ b/src/FirebaseProjectManager.php @@ -91,6 +91,16 @@ protected function configure(string $name): FirebaseProject if ($defaultStorageBucket = $config['storage']['default_bucket'] ?? null) { $factory = $factory->withDefaultStorageBucket($defaultStorageBucket); } + if ($logChannel = $config['logging']['http_debug_log_channel'] ?? null) { + $factory = $factory->withHttpDebugLogger( + $this->app->make('log')->channel($logChannel) + ); + } + + if ($config['debug'] ?? false) { + $logger = $this->app->make('log')->channel($logChannel ?? null); + $factory = $factory->withEnabledDebug($logger); + } if ($cacheStore = $config['cache_store'] ?? null) { $cache = $this->app->make('cache')->store($cacheStore); @@ -112,11 +122,7 @@ protected function configure(string $name): FirebaseProject ); } - if ($logChannel = $config['logging']['http_debug_log_channel'] ?? null) { - $factory = $factory->withHttpDebugLogger( - $this->app->make('log')->channel($logChannel) - ); - } + $options = HttpClientOptions::default(); diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index c14930e..d8f4e00 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -53,6 +53,11 @@ private function registerComponents(): void $this->app->singleton(Firebase\Contract\RemoteConfig::class, static fn (Container $app) => $app->make(FirebaseProjectManager::class)->project()->remoteConfig()); $this->app->alias(Firebase\Contract\RemoteConfig::class, 'firebase.remote_config'); + + $this->app->singleton(Firebase\IdentityPlatform::class, static function (Container $app) { + return $app->make(FirebaseProjectManager::class)->project()->identityPlatform(); + }); + $this->app->alias(Firebase\IdentityPlatform::class, 'firebase.identity_platform'); $this->app->singleton(Firebase\Contract\Storage::class, static fn (Container $app) => $app->make(FirebaseProjectManager::class)->project()->storage()); $this->app->alias(Firebase\Contract\Storage::class, 'firebase.storage'); }