Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: spatie/laravel-ray
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.35.1
Choose a base ref
...
head repository: spatie/laravel-ray
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref

Commits on Feb 13, 2024

  1. Update CHANGELOG

    Nielsvanpach authored and github-actions[bot] committed Feb 13, 2024

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    addaleax Anna Henningsen
    Copy the full SHA
    ad3359e View commit details

Commits on Mar 4, 2024

  1. Bump ramsey/composer-install from 2 to 3

    Bumps [ramsey/composer-install](https://github.com/ramsey/composer-install) from 2 to 3.
    - [Release notes](https://github.com/ramsey/composer-install/releases)
    - [Commits](ramsey/composer-install@v2...v3)
    
    ---
    updated-dependencies:
    - dependency-name: ramsey/composer-install
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Mar 4, 2024
    Copy the full SHA
    6c3287f View commit details
  2. Bump shivammathur/setup-php from 2.29.0 to 2.30.0

    Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.29.0 to 2.30.0.
    - [Release notes](https://github.com/shivammathur/setup-php/releases)
    - [Commits](shivammathur/setup-php@2.29.0...2.30.0)
    
    ---
    updated-dependencies:
    - dependency-name: shivammathur/setup-php
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Mar 4, 2024
    Copy the full SHA
    99ed4f8 View commit details

Commits on Mar 5, 2024

  1. Merge pull request #334 from spatie/dependabot/github_actions/shivamm…

    …athur/setup-php-2.30.0
    
    Bump shivammathur/setup-php from 2.29.0 to 2.30.0
    github-actions[bot] authored Mar 5, 2024
    Copy the full SHA
    e5672b9 View commit details

Commits on Mar 25, 2024

  1. Bump shivammathur/setup-php from 2.30.0 to 2.30.1

    Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.30.0 to 2.30.1.
    - [Release notes](https://github.com/shivammathur/setup-php/releases)
    - [Commits](shivammathur/setup-php@2.30.0...2.30.1)
    
    ---
    updated-dependencies:
    - dependency-name: shivammathur/setup-php
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Mar 25, 2024
    Copy the full SHA
    245a8c4 View commit details
  2. Bump dependabot/fetch-metadata from 1.6.0 to 2.0.0

    Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.6.0 to 2.0.0.
    - [Release notes](https://github.com/dependabot/fetch-metadata/releases)
    - [Commits](dependabot/fetch-metadata@v1.6.0...v2.0.0)
    
    ---
    updated-dependencies:
    - dependency-name: dependabot/fetch-metadata
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Mar 25, 2024
    Copy the full SHA
    855dac8 View commit details
  3. Merge pull request #335 from spatie/dependabot/github_actions/shivamm…

    …athur/setup-php-2.30.1
    
    Bump shivammathur/setup-php from 2.30.0 to 2.30.1
    github-actions[bot] authored Mar 25, 2024
    Copy the full SHA
    8888778 View commit details

Commits on Mar 29, 2024

  1. support context

    freekmurze committed Mar 29, 2024
    Copy the full SHA
    571f06a View commit details
  2. Merge pull request #336 from spatie/dependabot/github_actions/dependa…

    …bot/fetch-metadata-2.0.0
    
    Bump dependabot/fetch-metadata from 1.6.0 to 2.0.0
    freekmurze authored Mar 29, 2024
    Copy the full SHA
    4ac1346 View commit details
  3. Merge pull request #333 from spatie/dependabot/github_actions/ramsey/…

    …composer-install-3
    
    Bump ramsey/composer-install from 2 to 3
    freekmurze authored Mar 29, 2024
    Copy the full SHA
    22d8320 View commit details
  4. Fix styling

    freekmurze authored and github-actions[bot] committed Mar 29, 2024
    Copy the full SHA
    70761b2 View commit details
  5. fix tests

    freekmurze committed Mar 29, 2024
    Copy the full SHA
    eddcb60 View commit details
  6. wip

    freekmurze committed Mar 29, 2024
    Copy the full SHA
    e2faf99 View commit details
  7. Merge pull request #337 from spatie/support-context

    Support context
    freekmurze authored Mar 29, 2024
    Copy the full SHA
    f15936b View commit details
  8. Update CHANGELOG

    freekmurze authored and github-actions[bot] committed Mar 29, 2024
    Copy the full SHA
    630e270 View commit details

Commits on Apr 1, 2024

  1. Bump shivammathur/setup-php from 2.30.1 to 2.30.2

    Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.30.1 to 2.30.2.
    - [Release notes](https://github.com/shivammathur/setup-php/releases)
    - [Commits](shivammathur/setup-php@2.30.1...2.30.2)
    
    ---
    updated-dependencies:
    - dependency-name: shivammathur/setup-php
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 1, 2024
    Copy the full SHA
    f039561 View commit details
  2. Merge pull request #338 from spatie/dependabot/github_actions/shivamm…

    …athur/setup-php-2.30.2
    
    Bump shivammathur/setup-php from 2.30.1 to 2.30.2
    github-actions[bot] authored Apr 1, 2024
    Copy the full SHA
    3e35d0e View commit details

Commits on Apr 10, 2024

  1. Make implicit nullable param to explicit

    GromNaN committed Apr 10, 2024
    Copy the full SHA
    a6685e5 View commit details

Commits on Apr 11, 2024

  1. Merge pull request #340 from GromNaN/explicit-nullable

    Make implicit nullable param to explicit (PHP 8.4 compatibility)
    freekmurze authored Apr 11, 2024
    Copy the full SHA
    b8c8ff9 View commit details

Commits on Apr 12, 2024

  1. Update branch alias for version 1.x

    Instead of having to update the branch alias for each release, the branch `main` can be an alias for all upcoming `1.x` versions.
    GromNaN authored Apr 12, 2024
    Copy the full SHA
    36064e2 View commit details
  2. Merge pull request #341 from GromNaN/patch-1

    Update branch alias for version 1.x
    freekmurze authored Apr 12, 2024
    Copy the full SHA
    799eb88 View commit details
  3. Update CHANGELOG

    freekmurze authored and github-actions[bot] committed Apr 12, 2024
    Copy the full SHA
    f26b4c9 View commit details

Commits on Apr 22, 2024

  1. Bump shivammathur/setup-php from 2.30.2 to 2.30.3

    Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.30.2 to 2.30.3.
    - [Release notes](https://github.com/shivammathur/setup-php/releases)
    - [Commits](shivammathur/setup-php@2.30.2...2.30.3)
    
    ---
    updated-dependencies:
    - dependency-name: shivammathur/setup-php
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 22, 2024
    Copy the full SHA
    9181e11 View commit details
  2. Merge pull request #344 from spatie/dependabot/github_actions/shivamm…

    …athur/setup-php-2.30.3
    
    Bump shivammathur/setup-php from 2.30.2 to 2.30.3
    github-actions[bot] authored Apr 22, 2024
    Copy the full SHA
    86cc275 View commit details

Commits on Apr 29, 2024

  1. Bump dependabot/fetch-metadata from 2.0.0 to 2.1.0

    Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 2.0.0 to 2.1.0.
    - [Release notes](https://github.com/dependabot/fetch-metadata/releases)
    - [Commits](dependabot/fetch-metadata@v2.0.0...v2.1.0)
    
    ---
    updated-dependencies:
    - dependency-name: dependabot/fetch-metadata
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 29, 2024
    Copy the full SHA
    24c6f9a View commit details
  2. Bump shivammathur/setup-php from 2.30.3 to 2.30.4

    Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.30.3 to 2.30.4.
    - [Release notes](https://github.com/shivammathur/setup-php/releases)
    - [Commits](shivammathur/setup-php@2.30.3...2.30.4)
    
    ---
    updated-dependencies:
    - dependency-name: shivammathur/setup-php
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 29, 2024
    Copy the full SHA
    c7e8f2e View commit details
  3. Merge pull request #345 from spatie/dependabot/github_actions/dependa…

    …bot/fetch-metadata-2.1.0
    
    Bump dependabot/fetch-metadata from 2.0.0 to 2.1.0
    github-actions[bot] authored Apr 29, 2024
    Copy the full SHA
    14d8fe0 View commit details
  4. Merge pull request #346 from spatie/dependabot/github_actions/shivamm…

    …athur/setup-php-2.30.4
    
    Bump shivammathur/setup-php from 2.30.3 to 2.30.4
    github-actions[bot] authored Apr 29, 2024
    Copy the full SHA
    5043df8 View commit details

Commits on May 2, 2024

  1. Copy the full SHA
    1f07805 View commit details
  2. Merge branch 'main' of github.com:spatie/laravel-ray

    freekmurze committed May 2, 2024
    Copy the full SHA
    96675b2 View commit details
  3. Fix styling

    freekmurze authored and github-actions[bot] committed May 2, 2024
    Copy the full SHA
    1852faa View commit details
  4. Update CHANGELOG

    freekmurze authored and github-actions[bot] committed May 2, 2024
    Copy the full SHA
    aa7f21c View commit details

Commits on Jun 3, 2024

  1. Bump shivammathur/setup-php from 2.30.4 to 2.30.5

    Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.30.4 to 2.30.5.
    - [Release notes](https://github.com/shivammathur/setup-php/releases)
    - [Commits](shivammathur/setup-php@2.30.4...2.30.5)
    
    ---
    updated-dependencies:
    - dependency-name: shivammathur/setup-php
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Jun 3, 2024
    Copy the full SHA
    12898ff View commit details
  2. Merge pull request #350 from spatie/dependabot/github_actions/shivamm…

    …athur/setup-php-2.30.5
    
    Bump shivammathur/setup-php from 2.30.4 to 2.30.5
    github-actions[bot] authored Jun 3, 2024
    Copy the full SHA
    068fb45 View commit details

Commits on Jun 24, 2024

  1. Bump shivammathur/setup-php from 2.30.5 to 2.31.0

    Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.30.5 to 2.31.0.
    - [Release notes](https://github.com/shivammathur/setup-php/releases)
    - [Commits](shivammathur/setup-php@2.30.5...2.31.0)
    
    ---
    updated-dependencies:
    - dependency-name: shivammathur/setup-php
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Jun 24, 2024
    Copy the full SHA
    cfed638 View commit details
  2. Merge pull request #353 from spatie/dependabot/github_actions/shivamm…

    …athur/setup-php-2.31.0
    
    Bump shivammathur/setup-php from 2.30.5 to 2.31.0
    github-actions[bot] authored Jun 24, 2024
    Copy the full SHA
    7ac569a View commit details

Commits on Jul 2, 2024

  1. Allow zbateson/mail-mime-parser ^3.0

    JamesFreeman committed Jul 2, 2024
    Copy the full SHA
    708a2a2 View commit details
  2. Merge pull request #354 from JamesFreeman/bugfix/upgrade-mail-mime-pa…

    …rser
    
    Allow zbateson/mail-mime-parser ^3.0
    freekmurze authored Jul 2, 2024
    Copy the full SHA
    9becea4 View commit details
  3. Update CHANGELOG

    freekmurze authored and github-actions[bot] committed Jul 2, 2024
    Copy the full SHA
    776d2c0 View commit details
  4. Add 'measure' directive to RayServiceProvider

    A new Blade directive, 'measure', has been added to the RayServiceProvider.php file. This directive calls ray()->measure() method in the Laravel Blade templates.
    iurigustavo committed Jul 2, 2024
    Copy the full SHA
    defd696 View commit details

Commits on Jul 3, 2024

  1. Merge pull request #355 from iurigustavo/feature/add-measure-blade-di…

    …rective
    
    Add 'measure' directive to RayServiceProvider
    freekmurze authored Jul 3, 2024
    Copy the full SHA
    f57b294 View commit details
  2. Update CHANGELOG

    freekmurze authored and github-actions[bot] committed Jul 3, 2024
    Copy the full SHA
    0ebd808 View commit details

Commits on Jul 8, 2024

  1. Bump dependabot/fetch-metadata from 2.1.0 to 2.2.0

    Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 2.1.0 to 2.2.0.
    - [Release notes](https://github.com/dependabot/fetch-metadata/releases)
    - [Commits](dependabot/fetch-metadata@v2.1.0...v2.2.0)
    
    ---
    updated-dependencies:
    - dependency-name: dependabot/fetch-metadata
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Jul 8, 2024
    Copy the full SHA
    90eaa43 View commit details
  2. Merge pull request #356 from spatie/dependabot/github_actions/dependa…

    …bot/fetch-metadata-2.2.0
    
    Bump dependabot/fetch-metadata from 2.1.0 to 2.2.0
    github-actions[bot] authored Jul 8, 2024
    Copy the full SHA
    d37e2be View commit details

Commits on Jul 12, 2024

  1. Add the xray function to show all available variables in a Blade view.

    timvandijck committed Jul 12, 2024
    Copy the full SHA
    c2bedfd View commit details

Commits on Jul 15, 2024

  1. Update CHANGELOG

    timvandijck authored and github-actions[bot] committed Jul 15, 2024
    Copy the full SHA
    ac336d3 View commit details
  2. Bump shivammathur/setup-php from 2.31.0 to 2.31.1

    Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.31.0 to 2.31.1.
    - [Release notes](https://github.com/shivammathur/setup-php/releases)
    - [Commits](shivammathur/setup-php@2.31.0...2.31.1)
    
    ---
    updated-dependencies:
    - dependency-name: shivammathur/setup-php
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Jul 15, 2024
    Copy the full SHA
    15fc19a View commit details
  3. Merge pull request #358 from spatie/dependabot/github_actions/shivamm…

    …athur/setup-php-2.31.1
    
    Bump shivammathur/setup-php from 2.31.0 to 2.31.1
    github-actions[bot] authored Jul 15, 2024
    Copy the full SHA
    1d10366 View commit details

Commits on Nov 12, 2024

  1. Install rector/rector during first run of php artisan ray:clean

    instead of requiring `rector/rector`.
    
    Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
    crynobone committed Nov 12, 2024
    Copy the full SHA
    5e642a3 View commit details
  2. wip

    Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
    crynobone committed Nov 12, 2024
    Copy the full SHA
    c9fa643 View commit details
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ jobs:

- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.6.0
uses: dependabot/fetch-metadata@v2.3.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
compat-lookup: true
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -10,12 +10,12 @@ jobs:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@2.29.0
uses: shivammathur/setup-php@2.32.0
with:
php-version: 8.3

- name: Install composer dependencies
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3

- name: Run PHPStan
run: vendor/bin/phpstan --error-format=github
28 changes: 24 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -9,21 +9,35 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.3, 8.2, 8.1, 8.0, 7.4]
laravel: [11.*, 10.*, 9.*, 8.*, 7.*]
php: [8.4, 8.3, 8.2, 8.1, 8.0, 7.4]
laravel: [12.*, 11.*, 10.*, 9.*, 8.*, 7.*]
dependency-version: [prefer-stable]
include:
- laravel: 12.*
testbench: 10.*
rector: 2.*
- laravel: 11.*
testbench: 9.*
rector: 2.*
- laravel: 10.*
testbench: 8.*
rector: 1.*
- laravel: 9.*
testbench: 7.*
rector: 1.*
- laravel: 8.*
testbench: 6.*
rector: 1.*
- laravel: 7.*
testbench: 5.*
rector: 0.19.*
exclude:
- laravel: 12.*
php: 8.1
- laravel: 12.*
php: 8.0
- laravel: 12.*
php: 7.4
- laravel: 11.*
php: 8.1
- laravel: 11.*
@@ -34,12 +48,18 @@ jobs:
php: 8.0
- laravel: 10.*
php: 7.4
- laravel: 9.*
php: 8.4
- laravel: 9.*
php: 8.3
- laravel: 9.*
php: 7.4
- laravel: 8.*
php: 8.4
- laravel: 8.*
php: 8.3
- laravel: 7.*
php: 8.4
- laravel: 7.*
php: 8.3
- laravel: 7.*
@@ -54,7 +74,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@2.29.0
uses: shivammathur/setup-php@2.32.0
with:
php-version: ${{ matrix.php }}
extensions: fileinfo, dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
@@ -67,7 +87,7 @@ jobs:
- name: Install dependencies
run: |
composer update --${{ matrix.dependency-version }} --with=laravel/framework:${{ matrix.laravel }} --with=orchestra/testbench-core:${{ matrix.testbench }} --prefer-dist --no-interaction
composer update --${{ matrix.dependency-version }} --with=laravel/framework:${{ matrix.laravel }} --with=orchestra/testbench-core:${{ matrix.testbench }} --with=rector/rector:${{ matrix.rector }} --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/pest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -9,3 +9,4 @@ docs
phpunit.xml
psalm.xml
vendor
.phpunit.cache
99 changes: 99 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,105 @@

All notable changes to `laravel-ray` will be documented in this file

## 1.39.1 - 2025-02-05

### What's Changed

* Update Dependencies by @sweptsquash in https://github.com/spatie/laravel-ray/pull/369
* Bump shivammathur/setup-php from 2.31.1 to 2.32.0 by @dependabot in https://github.com/spatie/laravel-ray/pull/370
* Bump dependabot/fetch-metadata from 2.2.0 to 2.3.0 by @dependabot in https://github.com/spatie/laravel-ray/pull/371
* Supports Laravel 12 by @crynobone in https://github.com/spatie/laravel-ray/pull/372

**Full Changelog**: https://github.com/spatie/laravel-ray/compare/1.39.0...1.39.1

## 1.39.0 - 2024-12-11

### What's Changed

* Update the Rector dependency to version ^2.0.0-rc2 by @martio in https://github.com/spatie/laravel-ray/pull/368
* Install `rector/rector` during first run of `php artisan ray:clean` instead of requiring `rector/rector` by @crynobone in https://github.com/spatie/laravel-ray/pull/363
* Add conditional query watcher and convenience methods for update, delete, insert and select queries by @patrickomeara in https://github.com/spatie/laravel-ray/pull/359

### New Contributors

* @martio made their first contribution in https://github.com/spatie/laravel-ray/pull/368
* @patrickomeara made their first contribution in https://github.com/spatie/laravel-ray/pull/359

**Full Changelog**: https://github.com/spatie/laravel-ray/compare/1.38.0...1.39.0

## 1.37.1 - 2024-07-15

### What's Changed

* Add the xray directive to show all available variables in a Blade view.
* Bump dependabot/fetch-metadata from 2.1.0 to 2.2.0 by @dependabot in https://github.com/spatie/laravel-ray/pull/356

**Full Changelog**: https://github.com/spatie/laravel-ray/compare/1.37.0...1.37.1

## 1.37.0 - 2024-07-03

### What's Changed

* Add 'measure' directive to RayServiceProvider by @iurigustavo in https://github.com/spatie/laravel-ray/pull/355

### New Contributors

* @iurigustavo made their first contribution in https://github.com/spatie/laravel-ray/pull/355

**Full Changelog**: https://github.com/spatie/laravel-ray/compare/1.36.3...1.37.0

## 1.36.3 - 2024-07-02

### What's Changed

* Bump shivammathur/setup-php from 2.30.4 to 2.30.5 by @dependabot in https://github.com/spatie/laravel-ray/pull/350
* Bump shivammathur/setup-php from 2.30.5 to 2.31.0 by @dependabot in https://github.com/spatie/laravel-ray/pull/353
* Allow zbateson/mail-mime-parser ^3.0 by @JamesFreeman in https://github.com/spatie/laravel-ray/pull/354

### New Contributors

* @JamesFreeman made their first contribution in https://github.com/spatie/laravel-ray/pull/354

**Full Changelog**: https://github.com/spatie/laravel-ray/compare/1.36.2...1.36.3

## 1.36.2 - 2024-05-02

### What's Changed

- fix signed URLs in logged mailables

**Full Changelog**: https://github.com/spatie/laravel-ray/compare/1.36.1...1.36.2

## 1.36.1 - 2024-04-12

### What's Changed

* Bump shivammathur/setup-php from 2.30.1 to 2.30.2 by @dependabot in https://github.com/spatie/laravel-ray/pull/338
* Make implicit nullable param to explicit (PHP 8.4 compatibility) by @GromNaN in https://github.com/spatie/laravel-ray/pull/340
* Update branch alias for version 1.x by @GromNaN in https://github.com/spatie/laravel-ray/pull/341

### New Contributors

* @GromNaN made their first contribution in https://github.com/spatie/laravel-ray/pull/340

**Full Changelog**: https://github.com/spatie/laravel-ray/compare/1.36.0...1.36.1

## 1.36.0 - 2024-03-29

### What's Changed

* Bump shivammathur/setup-php from 2.29.0 to 2.30.0 by @dependabot in https://github.com/spatie/laravel-ray/pull/334
* Bump shivammathur/setup-php from 2.30.0 to 2.30.1 by @dependabot in https://github.com/spatie/laravel-ray/pull/335
* Bump dependabot/fetch-metadata from 1.6.0 to 2.0.0 by @dependabot in https://github.com/spatie/laravel-ray/pull/336
* Bump ramsey/composer-install from 2 to 3 by @dependabot in https://github.com/spatie/laravel-ray/pull/333
* Support context by @freekmurze in https://github.com/spatie/laravel-ray/pull/337

**Full Changelog**: https://github.com/spatie/laravel-ray/compare/1.35.1...1.36.0

## 1.35.1 - 2024-02-13

**Full Changelog**: https://github.com/spatie/laravel-ray/compare/1.35.0...1.35.1

## 1.35.0 - 2024-02-03

### What's Changed
81 changes: 41 additions & 40 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"name": "spatie/laravel-ray",
"description": "Easily debug Laravel apps",
"license": "MIT",
"keywords": [
"spatie",
"laravel-ray"
],
"homepage": "https://github.com/spatie/laravel-ray",
"license": "MIT",
"authors": [
{
"name": "Freek Van der Herten",
@@ -15,29 +14,43 @@
"role": "Developer"
}
],
"homepage": "https://github.com/spatie/laravel-ray",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/spatie"
},
{
"type": "other",
"url": "https://spatie.be/open-source/support-us"
}
],
"require": {
"php": "^7.4 || ^8.0",
"ext-json": "*",
"php": "^7.4|^8.0",
"illuminate/contracts": "^7.20|^8.19|^9.0|^10.0|^11.0",
"illuminate/database": "^7.20|^8.19|^9.0|^10.0|^11.0",
"illuminate/queue": "^7.20|^8.19|^9.0|^10.0|^11.0",
"illuminate/support": "^7.20|^8.19|^9.0|^10.0|^11.0",
"rector/rector": "^0.19.2|^1.0",
"spatie/backtrace": "^1.0",
"spatie/ray": "^1.41.1",
"symfony/stopwatch": "4.2|^5.1|^6.0|^7.0",
"zbateson/mail-mime-parser": "^1.3.1|^2.0"
"composer-runtime-api": "^2.2",
"illuminate/contracts": "^7.20 || ^8.19 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
"illuminate/database": "^7.20 || ^8.19 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
"illuminate/queue": "^7.20 || ^8.19 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
"illuminate/support": "^7.20 || ^8.19 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
"spatie/backtrace": "^1.7.1",
"spatie/ray": "^1.41.3",
"symfony/stopwatch": "4.2 || ^5.1 || ^6.0 || ^7.0",
"zbateson/mail-mime-parser": "^1.3.1 || ^2.0 || ^3.0"
},
"require-dev": {
"guzzlehttp/guzzle": "^7.3",
"laravel/framework": "^7.20|^8.19|^9.0|^10.0|^11.0",
"orchestra/testbench-core": "^5.0|^6.0|^7.0|^8.0|^9.0",
"pestphp/pest": "^1.22|^2.0",
"phpstan/phpstan": "^1.10.57",
"phpunit/phpunit": "^9.3|^10.1",
"spatie/pest-plugin-snapshots": "^1.1|^2.0",
"symfony/var-dumper": "^4.2|^5.1|^6.0|^7.0.3"
"laravel/framework": "^7.20 || ^8.19 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
"orchestra/testbench-core": "^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0",
"pestphp/pest": "^1.22 || ^2.0 || ^3.0",
"phpstan/phpstan": "^1.10.57 || ^2.0.2",
"phpunit/phpunit": "^9.3 || ^10.1 || ^11.0.10",
"rector/rector": "^0.19.2 || ^1.0.1 || ^2.0.0",
"spatie/pest-plugin-snapshots": "^1.1 || ^2.0",
"symfony/var-dumper": "^4.2 || ^5.1 || ^6.0 || ^7.0.3"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Spatie\\LaravelRay\\": "src"
@@ -48,38 +61,26 @@
"Spatie\\LaravelRay\\Tests\\": "tests"
}
},
"scripts": {
"analyse": "vendor/bin/phpstan",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-main": "1.29.x-dev"
"dev-main": "1.x-dev"
},
"laravel": {
"providers": [
"Spatie\\LaravelRay\\RayServiceProvider"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/spatie"
},
{
"type": "other",
"url": "https://spatie.be/open-source/support-us"
}
]
"scripts": {
"analyse": "vendor/bin/phpstan",
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage"
}
}
39 changes: 39 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -15,6 +15,11 @@ parameters:
count: 1
path: src/Watchers/ExceptionWatcher.php

-
message: "#^Call to method createReport\\(\\) on an unknown class Spatie\\\\FlareClient\\\\Flare\\.$#"
count: 1
path: src/Watchers/ExceptionWatcher.php

-
message: "#^Call to method trim\\(\\) on an unknown class Facade\\\\FlareClient\\\\Truncation\\\\ReportTrimmer\\.$#"
count: 1
@@ -50,3 +55,37 @@ parameters:
count: 1
path: src/Watchers/ExceptionWatcher.php

-
message: "#^Access to an undefined property Illuminate\\\\Support\\\\Optional::\\$file.$#"
count: 1
path: src/OriginFactory.php

-
message: "#^Access to an undefined property Illuminate\\\\Support\\\\Optional::\\$lineNumber.$#"
count: 1
path: src/OriginFactory.php

-
message: "#^Call to an undefined method Illuminate\\\\Support\\\\Optional::applyCalledMethods\\(\\).$#"
count: 10
path: src/

-
message: "#^Call to an undefined method Illuminate\\\\Support\\\\Optional::getActionName\\(\\).$#"
count: 1
path: src/Watchers/RequestWatcher.php

-
message: "#^Call to an undefined method Illuminate\\\\Support\\\\Optional::gatherMiddleware\\(\\).$#"
count: 1
path: src/Watchers/RequestWatcher.php

-
message: "#^Access to protected property Illuminate\\\\Support\\\\Collection::\\$items.$#"
count: 2
path: src/RayServiceProvider.php

-
message: "#^Access to protected property Illuminate\\\\Support\\\\Stringable::\\$value.$#"
count: 2
path: src/RayServiceProvider.php
7 changes: 2 additions & 5 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -12,8 +12,5 @@ parameters:
- '#^Call to method \w+\(\) on an unknown class Spatie\\RayBundle\\Ray\.$#'
- '#^Access to an undefined property Spatie\\Ray\\Settings\\Settings\:\:\$\w+\.$#'
-
message: '#^Access to an undefined property Spatie\\LaravelRay\\RayServiceProvider\:\:\$items\.$#'
path: src/RayServiceProvider.php
-
message: '#^Access to an undefined property Spatie\\LaravelRay\\RayServiceProvider\:\:\$value\.$#'
path: src/RayServiceProvider.php
message: '#Unsafe usage of new static\(\).#'
reportUnmatched: false
48 changes: 19 additions & 29 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
verbose="true"
>
<testsuites>
<testsuite name="Spatie Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="APP_DEBUG" value="true" />
<env name="CACHE_DRIVER" value="array" />
<env name="CACHE_STORE" value="array" />
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Spatie Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="APP_DEBUG" value="true"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="CACHE_STORE" value="array"/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
10 changes: 9 additions & 1 deletion src/Commands/CleanRayCommand.php
Original file line number Diff line number Diff line change
@@ -2,16 +2,19 @@

namespace Spatie\LaravelRay\Commands;

use Composer\InstalledVersions;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Process;
use Spatie\LaravelRay\Support\Composer;

class CleanRayCommand extends Command
{
protected $signature = 'ray:clean';

protected $description = 'Remove all Ray calls from your codebase.';

public function handle()
public function handle(Filesystem $files)
{
$directories = [
'app',
@@ -23,6 +26,11 @@ public function handle()
'tests',
];

if (! InstalledVersions::isInstalled('rector/rector')) {
(new Composer($files, defined('TESTBENCH_WORKING_PATH') ? TESTBENCH_WORKING_PATH : base_path()))
->requirePackages(['rector/rector'], true, $this->output);
}

$this->withProgressBar($directories, function ($directory) {
$result = Process::run('./vendor/bin/remove-ray.sh ' . $directory);

2 changes: 1 addition & 1 deletion src/DumpRecorder/MultiDumpHandler.php
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ public function dump($value)
}
}

public function addHandler(callable $callable = null): self
public function addHandler(?callable $callable = null): self
{
$this->handlers[] = $callable;

2 changes: 1 addition & 1 deletion src/Payloads/CachePayload.php
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ class CachePayload extends Payload
/** @var int|null */
protected $expirationInSeconds;

public function __construct(string $type, string $key, $tags, $value = null, int $expirationInSeconds = null)
public function __construct(string $type, string $key, $tags, $value = null, ?int $expirationInSeconds = null)
{
$this->type = $type;

16 changes: 15 additions & 1 deletion src/Payloads/LoggedMailPayload.php
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
use ZBateson\MailMimeParser\Header\AddressHeader;
use ZBateson\MailMimeParser\Header\HeaderConsts;
use ZBateson\MailMimeParser\Header\Part\AddressPart;
use ZBateson\MailMimeParser\IMessage;
use ZBateson\MailMimeParser\MailMimeParser;

class LoggedMailPayload extends Payload
@@ -34,7 +35,9 @@ public static function forLoggedMail(string $loggedMail): self

$message = $parser->parse($loggedMail, true);

$content = $message->getContent() ?? $message->getHtmlContent() ?? '';
// get the part in $loggedMail that starts with <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0

$content = self::getMailContent($loggedMail, $message);

return new self(
$content,
@@ -62,6 +65,17 @@ public function __construct(
$this->bcc = $bcc;
}

protected static function getMailContent(string $loggedMail, IMessage $message): string
{
$startOfHtml = strpos($loggedMail, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0', true);

if (! $startOfHtml) {
return $message->getContent() ?? $message->getHtmlContent() ?? '';
}

return substr($loggedMail, $startOfHtml) ?? '';
}

public function getType(): string
{
return 'mailable';
2 changes: 1 addition & 1 deletion src/Payloads/MailablePayload.php
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ public static function forMailable(Mailable $mailable)
return new self(self::renderMailable($mailable), $mailable);
}

public function __construct(string $html, Mailable $mailable = null)
public function __construct(string $html, ?Mailable $mailable = null)
{
$this->html = $html;

132 changes: 130 additions & 2 deletions src/Ray.php
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
use Illuminate\Mail\Mailable;
use Illuminate\Mail\MailManager;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Context;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Testing\Fakes\MailFake;
@@ -25,14 +26,19 @@
use Spatie\LaravelRay\Payloads\ResponsePayload;
use Spatie\LaravelRay\Payloads\ViewPayload;
use Spatie\LaravelRay\Watchers\CacheWatcher;
use Spatie\LaravelRay\Watchers\ConditionalQueryWatcher;
use Spatie\LaravelRay\Watchers\DeleteQueryWatcher;
use Spatie\LaravelRay\Watchers\DuplicateQueryWatcher;
use Spatie\LaravelRay\Watchers\EventWatcher;
use Spatie\LaravelRay\Watchers\ExceptionWatcher;
use Spatie\LaravelRay\Watchers\HttpClientWatcher;
use Spatie\LaravelRay\Watchers\InsertQueryWatcher;
use Spatie\LaravelRay\Watchers\JobWatcher;
use Spatie\LaravelRay\Watchers\QueryWatcher;
use Spatie\LaravelRay\Watchers\RequestWatcher;
use Spatie\LaravelRay\Watchers\SelectQueryWatcher;
use Spatie\LaravelRay\Watchers\SlowQueryWatcher;
use Spatie\LaravelRay\Watchers\UpdateQueryWatcher;
use Spatie\LaravelRay\Watchers\ViewWatcher;
use Spatie\LaravelRay\Watchers\Watcher;
use Spatie\Ray\Client;
@@ -43,7 +49,7 @@

class Ray extends BaseRay
{
public function __construct(Settings $settings, Client $client = null, string $uuid = null)
public function __construct(Settings $settings, ?Client $client = null, ?string $uuid = null)
{
// persist the enabled setting across multiple instantiations
$enabled = static::$enabled;
@@ -85,6 +91,58 @@ public function mailable(Mailable ...$mailables): self
return $this;
}

/**
* @param array|string ...$keys
*
* @return $this
*/
public function context(...$keys): self
{
if (! class_exists(Context::class)) {
return $this;
}

if (isset($keys[0]) && is_array($keys[0])) {
$keys = $keys[0];
}

$context = count($keys)
? Context::only($keys)
: Context::all();

$this
->send($context)
->label('Context');

return $this;
}

/**
* @param array|string ...$keys
*
* @return $this
*/
public function hiddenContext(...$keys): self
{
if (! class_exists(Context::class)) {
return $this;
}

if (isset($keys[0]) && is_array($keys[0])) {
$keys = $keys[0];
}

$hiddenContext = count($keys)
? Context::onlyHidden($keys)
: Context::allHidden();

$this
->send($hiddenContext)
->label('Hidden Context');

return $this;
}

/**
* @param Model|iterable ...$model
*
@@ -380,6 +438,76 @@ public function stopShowingDuplicateQueries(): self
return $this;
}

public function showConditionalQueries(Closure $condition, $callable = null, $name = 'default')
{
$watcher = ConditionalQueryWatcher::buildWatcherForName($condition, $name);

return $this->handleWatcherCallable($watcher, $callable);
}

public function stopShowingConditionalQueries($name = 'default'): self
{
app(ConditionalQueryWatcher::abstractName($name))->disable();

return $this;
}

public function showUpdateQueries($callable = null)
{
$watcher = app(UpdateQueryWatcher::class);

return $this->handleWatcherCallable($watcher, $callable);
}

public function stopShowingUpdateQueries(): self
{
app(UpdateQueryWatcher::class)->disable();

return $this;
}

public function showDeleteQueries($callable = null)
{
$watcher = app(DeleteQueryWatcher::class);

return $this->handleWatcherCallable($watcher, $callable);
}

public function stopShowingDeleteQueries(): self
{
app(DeleteQueryWatcher::class)->disable();

return $this;
}

public function showInsertQueries($callable = null)
{
$watcher = app(InsertQueryWatcher::class);

return $this->handleWatcherCallable($watcher, $callable);
}

public function stopShowingInsertQueries(): self
{
app(InsertQueryWatcher::class)->disable();

return $this;
}

public function showSelectQueries($callable = null)
{
$watcher = app(SelectQueryWatcher::class);

return $this->handleWatcherCallable($watcher, $callable);
}

public function stopShowingSelectQueries(): self
{
app(SelectQueryWatcher::class)->disable();

return $this;
}

/**
* @param null $callable
*
@@ -434,7 +562,7 @@ public function stopShowingHttpClientRequests(): self
return $this;
}

protected function handleWatcherCallable(Watcher $watcher, Closure $callable = null)
protected function handleWatcherCallable(Watcher $watcher, ?Closure $callable = null)
{
$rayProxy = new RayProxy();

22 changes: 22 additions & 0 deletions src/RayServiceProvider.php
Original file line number Diff line number Diff line change
@@ -18,17 +18,21 @@
use Spatie\LaravelRay\Payloads\QueryPayload;
use Spatie\LaravelRay\Watchers\ApplicationLogWatcher;
use Spatie\LaravelRay\Watchers\CacheWatcher;
use Spatie\LaravelRay\Watchers\DeleteQueryWatcher;
use Spatie\LaravelRay\Watchers\DeprecatedNoticeWatcher;
use Spatie\LaravelRay\Watchers\DumpWatcher;
use Spatie\LaravelRay\Watchers\DuplicateQueryWatcher;
use Spatie\LaravelRay\Watchers\EventWatcher;
use Spatie\LaravelRay\Watchers\ExceptionWatcher;
use Spatie\LaravelRay\Watchers\HttpClientWatcher;
use Spatie\LaravelRay\Watchers\InsertQueryWatcher;
use Spatie\LaravelRay\Watchers\JobWatcher;
use Spatie\LaravelRay\Watchers\LoggedMailWatcher;
use Spatie\LaravelRay\Watchers\QueryWatcher;
use Spatie\LaravelRay\Watchers\RequestWatcher;
use Spatie\LaravelRay\Watchers\SelectQueryWatcher;
use Spatie\LaravelRay\Watchers\SlowQueryWatcher;
use Spatie\LaravelRay\Watchers\UpdateQueryWatcher;
use Spatie\LaravelRay\Watchers\ViewWatcher;
use Spatie\Ray\Client;
use Spatie\Ray\PayloadFactory;
@@ -79,6 +83,10 @@ protected function registerSettings(): self
'send_queries_to_ray' => env('SEND_QUERIES_TO_RAY', false),
'send_duplicate_queries_to_ray' => env('SEND_DUPLICATE_QUERIES_TO_RAY', false),
'send_slow_queries_to_ray' => env('SEND_SLOW_QUERIES_TO_RAY', false),
'send_update_queries_to_ray' => env('SEND_UPDATE_QUERIES_TO_RAY', false),
'send_insert_queries_to_ray' => env('SEND_INSERT_QUERIES_TO_RAY', false),
'send_delete_queries_to_ray' => env('SEND_DELETE_QUERIES_TO_RAY', false),
'send_select_queries_to_ray' => env('SEND_SELECT_QUERIES_TO_RAY', false),
'send_requests_to_ray' => env('SEND_REQUESTS_TO_RAY', false),
'send_http_client_requests_to_ray' => env('SEND_HTTP_CLIENT_REQUESTS_TO_RAY', false),
'send_views_to_ray' => env('SEND_VIEWS_TO_RAY', false),
@@ -142,6 +150,10 @@ protected function registerWatchers(): self
QueryWatcher::class,
DuplicateQueryWatcher::class,
SlowQueryWatcher::class,
InsertQueryWatcher::class,
SelectQueryWatcher::class,
UpdateQueryWatcher::class,
DeleteQueryWatcher::class,
ViewWatcher::class,
CacheWatcher::class,
RequestWatcher::class,
@@ -169,6 +181,10 @@ protected function bootWatchers(): self
QueryWatcher::class,
DuplicateQueryWatcher::class,
SlowQueryWatcher::class,
InsertQueryWatcher::class,
SelectQueryWatcher::class,
UpdateQueryWatcher::class,
DeleteQueryWatcher::class,
ViewWatcher::class,
CacheWatcher::class,
RequestWatcher::class,
@@ -234,6 +250,12 @@ protected function registerBladeDirectives(): self
Blade::directive('ray', function ($expression) {
return "<?php ray($expression); ?>";
});
Blade::directive('measure', function () {
return '<?php ray()->measure() ?>';
});
Blade::directive('xray', function () {
return '<?php ray($__data)?>';
});
});

return $this;
40 changes: 40 additions & 0 deletions src/Support/Composer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Spatie\LaravelRay\Support;

use Closure;
use Symfony\Component\Console\Output\OutputInterface;

class Composer extends \Illuminate\Support\Composer
{
/**
* Install the given Composer packages into the application.
*
* Override this method for `illuminate/support` 10 and below.
*
* @param array<int, string> $packages
* @param bool $dev
* @param \Closure|\Symfony\Component\Console\Output\OutputInterface|null $output
* @param string|null $composerBinary
* @return bool
*/
public function requirePackages(array $packages, bool $dev = false, Closure|OutputInterface|null $output = null, $composerBinary = null)
{
$command = collect([
...$this->findComposer($composerBinary),
'require',
...$packages,
])
->when($dev, function ($command) {
$command->push('--dev');
})->all();

return 0 === $this->getProcess($command, ['COMPOSER_MEMORY_LIMIT' => '-1'])
->run(
$output instanceof OutputInterface
? function ($type, $line) use ($output) {
$output->write(' '.$line);
} : $output
);
}
}
63 changes: 63 additions & 0 deletions src/Watchers/ConditionalQueryWatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Spatie\LaravelRay\Watchers;

use BadMethodCallException;
use Closure;
use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Support\Facades\Event;
use Spatie\LaravelRay\Payloads\ExecutedQueryPayload;
use Spatie\LaravelRay\Ray;

class ConditionalQueryWatcher extends QueryWatcher
{
protected $conditionalCallback;

public static function buildWatcherForName(Closure $condition, $name)
{
$watcher = new static();
$watcher->setConditionalCallback($condition);

return app()->instance(static::abstractName($name), $watcher);
}

public static function abstractName(string $name)
{
return static::class.':'.$name;
}

public function setConditionalCallback($conditionalCallback)
{
$this->conditionalCallback = $conditionalCallback;

$this->listen();
}

public function register(): void
{
throw new BadMethodCallException('ConditionalQueryWatcher cannot be registered. Only its child classes.');
}

public function listen(): void
{
Event::listen(QueryExecuted::class, function (QueryExecuted $query) {
if (! $this->enabled()) {
return;
}

if (! $this->conditionalCallback) {
return;
}

$ray = app(Ray::class);

if (($this->conditionalCallback)($query)) {
$payload = new ExecutedQueryPayload($query);

$ray->sendRequest($payload);
}

optional($this->rayProxy)->applyCalledMethods($ray);
});
}
}
21 changes: 21 additions & 0 deletions src/Watchers/DeleteQueryWatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Spatie\LaravelRay\Watchers;

use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Support\Str;
use Spatie\Ray\Settings\Settings;

class DeleteQueryWatcher extends ConditionalQueryWatcher
{
public function register(): void
{
$settings = app(Settings::class);

$this->enabled = $settings->send_delete_queries_to_ray ?? false;

$this->setConditionalCallback(function (QueryExecuted $query) {
return Str::startsWith(strtolower($query->sql), 'delete');
});
}
}
21 changes: 21 additions & 0 deletions src/Watchers/InsertQueryWatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Spatie\LaravelRay\Watchers;

use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Support\Str;
use Spatie\Ray\Settings\Settings;

class InsertQueryWatcher extends ConditionalQueryWatcher
{
public function register(): void
{
$settings = app(Settings::class);

$this->enabled = $settings->send_insert_queries_to_ray ?? false;

$this->setConditionalCallback(function (QueryExecuted $query) {
return Str::startsWith(strtolower($query->sql), 'insert');
});
}
}
21 changes: 21 additions & 0 deletions src/Watchers/SelectQueryWatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Spatie\LaravelRay\Watchers;

use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Support\Str;
use Spatie\Ray\Settings\Settings;

class SelectQueryWatcher extends ConditionalQueryWatcher
{
public function register(): void
{
$settings = app(Settings::class);

$this->enabled = $settings->send_select_queries_to_ray ?? false;

$this->setConditionalCallback(function (QueryExecuted $query) {
return Str::startsWith(strtolower($query->sql), 'select');
});
}
}
21 changes: 3 additions & 18 deletions src/Watchers/SlowQueryWatcher.php
Original file line number Diff line number Diff line change
@@ -3,12 +3,9 @@
namespace Spatie\LaravelRay\Watchers;

use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Support\Facades\Event;
use Spatie\LaravelRay\Payloads\ExecutedQueryPayload;
use Spatie\LaravelRay\Ray;
use Spatie\Ray\Settings\Settings;

class SlowQueryWatcher extends QueryWatcher
class SlowQueryWatcher extends ConditionalQueryWatcher
{
protected $minimumTimeInMs = 500;

@@ -19,20 +16,8 @@ public function register(): void
$this->enabled = $settings->send_slow_queries_to_ray ?? false;
$this->minimumTimeInMs = $settings->slow_query_threshold_in_ms ?? $this->minimumTimeInMs;

Event::listen(QueryExecuted::class, function (QueryExecuted $query) {
if (! $this->enabled()) {
return;
}

$ray = app(Ray::class);

if ($query->time >= $this->minimumTimeInMs) {
$payload = new ExecutedQueryPayload($query);

$ray->sendRequest($payload);
}

optional($this->rayProxy)->applyCalledMethods($ray);
$this->setConditionalCallback(function (QueryExecuted $query) {
return $query->time >= $this->minimumTimeInMs;
});
}

21 changes: 21 additions & 0 deletions src/Watchers/UpdateQueryWatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Spatie\LaravelRay\Watchers;

use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Support\Str;
use Spatie\Ray\Settings\Settings;

class UpdateQueryWatcher extends ConditionalQueryWatcher
{
public function register(): void
{
$settings = app(Settings::class);

$this->enabled = $settings->send_update_queries_to_ray ?? false;

$this->setConditionalCallback(function (QueryExecuted $query) {
return Str::startsWith(strtolower($query->sql), 'update');
});
}
}
20 changes: 20 additions & 0 deletions stub/ray.php
Original file line number Diff line number Diff line change
@@ -50,6 +50,26 @@
*/
'slow_query_threshold_in_ms' => env('RAY_SLOW_QUERY_THRESHOLD_IN_MS', 500),

/*
* When enabled, all update queries will automatically be sent to Ray.
*/
'send_update_queries_to_ray' => env('SEND_UPDATE_QUERIES_TO_RAY', false),

/*
* When enabled, all insert queries will automatically be sent to Ray.
*/
'send_insert_queries_to_ray' => env('SEND_INSERT_QUERIES_TO_RAY', false),

/*
* When enabled, all delete queries will automatically be sent to Ray.
*/
'send_delete_queries_to_ray' => env('SEND_DELETE_QUERIES_TO_RAY', false),

/*
* When enabled, all select queries will automatically be sent to Ray.
*/
'send_select_queries_to_ray' => env('SEND_SELECT_QUERIES_TO_RAY', false),

/*
* When enabled, all requests made to this app will automatically be sent to Ray.
*/
6 changes: 6 additions & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
|--------------------------------------------------------------------------
*/

use Illuminate\Support\Facades\Context;
use Spatie\LaravelRay\Tests\TestCase;

uses(TestCase::class)->in('.');
@@ -32,3 +33,8 @@ function assertMatchesOsSafeSnapshot($data): void

test()->expect($json)->toMatchJsonSnapshot();
}

function contextSupported(): bool
{
return class_exists(Context::class);
}
11 changes: 11 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -2,9 +2,11 @@

namespace Spatie\LaravelRay\Tests;

use Illuminate\Database\Query\Builder;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Str;
use Orchestra\Testbench\TestCase as Orchestra;
use Spatie\LaravelRay\Ray;
use Spatie\LaravelRay\RayServiceProvider;
@@ -70,4 +72,13 @@ protected function useRealUuid()
return Ray::create($this->client);
});
}

protected function assertSqlContains($queryContent, $needle): void
{
$sql = method_exists(Builder::class, 'toRawSql')
? $queryContent['sql']
: Str::replaceArray('?', $queryContent['bindings'], $queryContent['sql']);

$this->assertStringContainsString($needle, $sql);
}
}
138 changes: 138 additions & 0 deletions tests/Unit/ConditionalQueryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<?php

use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Spatie\LaravelRay\Tests\TestClasses\User;
use Spatie\LaravelRay\Watchers\SelectQueryWatcher;
use Spatie\Ray\Settings\Settings;

it('can show only update queries and return the results', function () {
$user = ray()->showUpdateQueries(function (): User {
$user = User::query()->create(['email' => 'john@example.com']);
$user->update(['email' => 'joan@example.com']);

return $user;
});

expect($this->client->sentRequests())->toHaveCount(1);
expect($user)->toBeInstanceOf(User::class);

$this->assertSame('joan@example.com', $user->email);
});

it('can show only type queries', function (string $rayShowMethod, string $rayStopMethod, string $sqlCommand) {
ray()->$rayShowMethod();

// Run all query types
$user = User::query()->firstOrCreate(['email' => 'john@example.com']);
$user->update(['email' => 'joan@example.com']);
$user->delete();

expect($this->client->sentPayloads())->toHaveCount(1);

// Assert the one we want is picked up.
$payload = $this->client->sentPayloads();
$this->assertSqlContains(Arr::get($payload, '0.content'), $sqlCommand);

ray()->$rayStopMethod();

// Assert that watcher has stopped.
$user = User::query()->firstOrCreate(['email' => 'sam@example.com']);
$user->update(['email' => 'sarah@example.com']);
$user->delete();

expect($this->client->sentPayloads())->toHaveCount(1);
})->with([
'update' => ['showUpdateQueries', 'stopShowingUpdateQueries', 'update'],
'delete' => ['showDeleteQueries', 'stopShowingDeleteQueries', 'delete'],
'insert' => ['showInsertQueries', 'stopShowingInsertQueries', 'insert'],
'select' => ['showSelectQueries', 'stopShowingSelectQueries', 'select'],
]);

it('can take a custom condition and only return those queries', function () {
ray()->showConditionalQueries(function (QueryExecuted $query) {
return Arr::first($query->bindings, fn ($binding) => Str::contains($binding, 'joan'));
});

User::query()->create(['email' => 'joan@example.com']);
User::query()->create(['email' => 'john@example.com']);

expect($this->client->sentPayloads())->toHaveCount(1);

$payload = $this->client->sentPayloads();
$this->assertSqlContains(Arr::get($payload, '0.content'), 'joan@example.com');

ray()->stopShowingConditionalQueries();

User::query()->create(['email' => 'joanne@example.com']);

expect($this->client->sentPayloads())->toHaveCount(1);
});

it('can handle multiple conditional query watchers', function () {
$john = ray()->showConditionalQueries(
function (QueryExecuted $query) {
return Arr::first($query->bindings, fn ($binding) => Str::contains($binding, 'joan'));
},
function (): User {
ray()->showConditionalQueries(
function (QueryExecuted $query) {
return Arr::first($query->bindings, fn ($binding) => Str::contains($binding, 'john'));
},
null,
'look for john'
);

User::query()->create(['email' => 'joan@example.com']);
User::query()->create(['email' => 'joe@example.com']);

return User::query()->create(['email' => 'john@example.com']);
},
'look for joan'
);

// Assert that john was handed back
$this->assertSame('john@example.com', $john->email);

// Assert that ray only received what we wanted
expect($this->client->sentPayloads())->toHaveCount(2);

$payload = $this->client->sentPayloads();

// Assert that ray received the correct order
$this->assertSqlContains(Arr::get($payload, '0.content'), 'joan@example.com');
$this->assertSqlContains(Arr::get($payload, '1.content'), 'john@example.com');

// Looking for joan has been disabled so this should not be sent
$joan = User::query()->where('email', 'joan@example.com')->first();
expect($this->client->sentPayloads())->toHaveCount(2);

// Looking for john is still enabled so this should be sent
$john->update(['email' => 'john@adifferentdomain.com']);
expect($this->client->sentPayloads())->toHaveCount(3);

ray()->stopShowingConditionalQueries('look for john');

// Looking for john has been disabled so this should not be sent
$joan->update(['email' => 'iamjohnnow@example.com']);
expect($this->client->sentPayloads())->toHaveCount(3);
});

it('can start watching from config only', function () {
app(Settings::class)->send_select_queries_to_ray = true;

// Refresh the watcher and register again to pick up settings change
$this->app->singleton(SelectQueryWatcher::class);
app(SelectQueryWatcher::class)->register();

// Run all query types
$user = User::query()->firstOrCreate(['email' => 'john@example.com']);
$user->update(['email' => 'joan@example.com']);
$user->delete();

expect($this->client->sentPayloads())->toHaveCount(1);

$payload = $this->client->sentPayloads();
$this->assertSqlContains(Arr::get($payload, '0.content'), 'select');
});
86 changes: 86 additions & 0 deletions tests/Unit/ContextTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace Spatie\LaravelRay\Tests\Unit;

use Illuminate\Support\Facades\Context;

it('can send all context', function () {
if (! contextSupported()) {
return;
}

Context::add('key', 'value');

ray()->context();

expect($this->client->sentRequests())->toHaveCount(2);

$requests = $this->client->sentRequests();

$clipboardData = $requests[0]['payloads'][0]['content']['meta']['0']['clipboard_data'];

expect($clipboardData)->toContain('key', 'value');
});


it('can send specific context keys variadic', function () {
if (! contextSupported()) {
return;
}

Context::add('key1', 'value1');
Context::add('key2', 'value2');
Context::add('key3', 'value3');

ray()->context('key1', 'key3');

expect($this->client->sentRequests())->toHaveCount(2);

$requests = $this->client->sentRequests();

$clipboardData = $requests[0]['payloads'][0]['content']['meta']['0']['clipboard_data'];

expect($clipboardData)->toContain('key1', 'key3');
expect($clipboardData)->not()->toContain('key2');
});

it('can send specific context keys using an array', function () {
if (! contextSupported()) {
return;
}

Context::add('key1', 'value1');
Context::add('key2', 'value2');
Context::add('key3', 'value3');

ray()->context(['key1', 'key3']);

expect($this->client->sentRequests())->toHaveCount(2);

$requests = $this->client->sentRequests();

$clipboardData = $requests[0]['payloads'][0]['content']['meta']['0']['clipboard_data'];

expect($clipboardData)->toContain('key1', 'key3');
expect($clipboardData)->not()->toContain('key2');
});

it('can send all hidden context', function () {
if (! contextSupported()) {
return;
}

Context::addHidden('hidden-key', 'hidden-value');
Context::add('visible-key', 'visible-value');

ray()->hiddenContext();

expect($this->client->sentRequests())->toHaveCount(2);

$requests = $this->client->sentRequests();

$clipboardData = $requests[0]['payloads'][0]['content']['meta']['0']['clipboard_data'];

expect($clipboardData)->toContain('hidden-key');
expect($clipboardData)->not()->toContain('visible-key');
});
9 changes: 7 additions & 2 deletions tests/Unit/MarkdownTest.php
Original file line number Diff line number Diff line change
@@ -8,9 +8,14 @@
assertMatchesOsSafeSnapshot($this->client->sentRequests());
})->skip(version_compare(version(), '2.0.0', '>='));


it('can render and send markdown for Pest 2', function () {
ray()->markdown('## Hello World!');

assertMatchesOsSafeSnapshot($this->client->sentRequests());
})->skip(version_compare(version(), '2.0.0', '<'));
})->skip(version_compare(version(), '2.0.0', '>=') || version_compare(version(), '3.0.0', '<'));

it('can render and send markdown for Pest 3', function () {
ray()->markdown('## Hello World!');

assertMatchesOsSafeSnapshot($this->client->sentRequests());
})->skip(version_compare(version(), '3.0.0', '<'));
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"uuid": "fakeUuid",
"payloads": [
{
"type": "custom",
"content": {
"content": "<style>a { text-decoration:underline!important; }</style><div class=\"w-100 block\" style=\"font-size:1.8em!important;\">Hello World!</div>",
"label": "Markdown"
},
"origin": {
"file": "/vendor/pestphp/pest/src/Factories/TestCaseMethodFactory.php",
"line_number": 168,
"hostname": "fake-hostname"
}
}
],
"meta": []
}
]