Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .github/workflows/dependabot-auto-merge.yml

This file was deleted.

118 changes: 55 additions & 63 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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 }}
18 changes: 16 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
Expand Down
19 changes: 19 additions & 0 deletions src/Facades/FirebaseIdentityPlatform.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Kreait\Laravel\Firebase\Facades;

use Illuminate\Support\Facades\Facade;

/**
* @see \Kreait\Firebase\Contract\IdentityPlatform
* @deprecated 3.0 Use {@see \Kreait\Laravel\Firebase\Facades\Firebase::auth()} instead.
*/
final class FirebaseIdentityPlatform extends Facade
{
protected static function getFacadeAccessor()
{
return 'firebase.identity_platform';
}
}
15 changes: 15 additions & 0 deletions src/FirebaseProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class FirebaseProject

protected ?DynamicLinks $dynamicLinks = null;

/** @var \Kreait\Firebase\Contract\IdentityPlatform|null */
protected $identityPlatform;

/** @var \Kreait\Firebase\Contract\Messaging|null */
protected $messaging;
protected ?Firestore $firestore = null;

protected ?Messaging $messaging = null;
Expand Down Expand Up @@ -60,6 +65,16 @@ public function auth(): Auth
return $this->auth;
}

public function identityPlatform(): Firebase\IdentityPlatform
{
if (!$this->identityPlatform) {
$this->identityPlatform = $this->factory->createIdentityPlatform();
}

return $this->identityPlatform;
}


public function database(): Database
{
if (! $this->database) {
Expand Down
16 changes: 11 additions & 5 deletions src/FirebaseProjectManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();

Expand Down
5 changes: 5 additions & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down