Skip to content

Fix crash in GuidelineAssist when app/ directory does not exist#617

Merged
pushpak1300 merged 1 commit intolaravel:mainfrom
mforcer:fix/guideline-assist-crash-without-app-directory
Mar 2, 2026
Merged

Fix crash in GuidelineAssist when app/ directory does not exist#617
pushpak1300 merged 1 commit intolaravel:mainfrom
mforcer:fix/guideline-assist-crash-without-app-directory

Conversation

@mforcer
Copy link
Contributor

@mforcer mforcer commented Mar 2, 2026

The Issue

During the installation process (php artisan boost:install), shouldEnforceStrictTypes() and enumContents() calls file_get_contents() on the value returned by current($this->modelPaths / $this->enumPaths) without checking whether it is a real file.

When app_path() is not a directory, discover() returns a sentinel array whose value is the app directory path - causing file_get_contents() to receive a directory and throw a fatal error.

This fixes projects using non-standard folder structures where no app/ directory exists.

We're using it in a project with Ports & Adapters architecture and the Laravel app is buried in a folder similar to src/.../Infrastructure/Laravel

Solution

Add is_file() guard to both methods so they return their safe defaults (false / '') when the path is not a real file, completing the graceful degradation path already established in discover().

While this doesn't really maintain the same level of support for all of the different architectures where Laravel can be used, it will allow the installation to complete successfully with sensible defaults.

shouldEnforceStrictTypes() and enumContents() called file_get_contents()
on the value returned by current($this->modelPaths / $this->enumPaths)
without checking whether it was a real file. When app_path() is not a
directory, discover() returns a sentinel array whose value is the app
directory path — causing file_get_contents() to receive a directory and
throw a fatal error.

Add is_file() guards to both methods so they return their safe defaults
(false / '') when the path is not a real file, completing the graceful
degradation path already established in discover().

Fixes projects using non-standard folder structures (DDD, hexagonal
architecture) where no app/ directory exists.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pushpak1300 pushpak1300 merged commit f814fb3 into laravel:main Mar 2, 2026
17 checks passed
@mforcer mforcer deleted the fix/guideline-assist-crash-without-app-directory branch March 2, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants