<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Houssem BEN ABDALLAH</title>
    <description>The latest articles on DEV Community by Houssem BEN ABDALLAH (@hbenabdallah).</description>
    <link>https://dev.to/hbenabdallah</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4256067%2F44f9b5c2-551a-451a-83fc-304c023195b6.jpg</url>
      <title>DEV Community: Houssem BEN ABDALLAH</title>
      <link>https://dev.to/hbenabdallah</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hbenabdallah"/>
    <language>en</language>
    <item>
      <title>What does this change break? Teaching an AI agent to see through Laravel facades</title>
      <dc:creator>Houssem BEN ABDALLAH</dc:creator>
      <pubDate>Fri, 20 Nov 2026 16:48:49 +0000</pubDate>
      <link>https://dev.to/hbenabdallah/what-does-this-change-break-teaching-an-ai-agent-to-see-through-laravel-facades-4nil</link>
      <guid>https://dev.to/hbenabdallah/what-does-this-change-break-teaching-an-ai-agent-to-see-through-laravel-facades-4nil</guid>
      <description>&lt;p&gt;Ask a coding agent to change &lt;code&gt;ThemeService::dispatch()&lt;/code&gt; in &lt;a href="https://github.com/BookStackApp/BookStack" rel="noopener noreferrer"&gt;BookStack&lt;/a&gt; and it will do what you would do: search for &lt;code&gt;-&amp;gt;dispatch(&lt;/code&gt; and &lt;code&gt;ThemeService&lt;/code&gt;, read what comes back, and edit. It finds one caller.&lt;/p&gt;

&lt;p&gt;There are 19 call sites. They look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;Theme&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ThemeEvents&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;AUTH_LOGIN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$method&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Theme&lt;/code&gt; is a facade:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Theme&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Facade&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getFacadeAccessor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;ThemeService&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No &lt;code&gt;@mixin&lt;/code&gt;, no &lt;code&gt;@method&lt;/code&gt;. Nothing written in the code links &lt;code&gt;Theme::dispatch()&lt;/code&gt; to &lt;code&gt;ThemeService::dispatch()&lt;/code&gt;. A person who knows Laravel makes the jump without thinking. A grep doesn't, and neither does an agent that only has grep.&lt;/p&gt;

&lt;h2&gt;
  
  
  A graph instead of a grep
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/alpine-ronin/phpgraph" rel="noopener noreferrer"&gt;phpgraph&lt;/a&gt; builds a knowledge graph of a PHP project by static analysis: classes, methods, calls, routes, messages and their handlers. Every relation has a confidence level: read in the code, inferred from declared types, or guessed. There is no LLM and no network call. It never boots your application: the code is parsed, not run. Agents use it through MCP (Claude Code, Codex, Cursor…), or you use it from the command line.&lt;/p&gt;

&lt;p&gt;Since 2.4.0, it follows facades. When a facade has no &lt;code&gt;@mixin&lt;/code&gt; or &lt;code&gt;@method&lt;/code&gt; for the method called, phpgraph reads &lt;code&gt;getFacadeAccessor()&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;if it returns &lt;code&gt;X::class&lt;/code&gt;, the call goes to &lt;code&gt;X&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;if it returns a key (&lt;code&gt;'steam'&lt;/code&gt;, &lt;code&gt;'preferences'&lt;/code&gt;), phpgraph looks for that key in your service providers: &lt;code&gt;bind()&lt;/code&gt;, &lt;code&gt;singleton()&lt;/code&gt;, &lt;code&gt;scoped()&lt;/code&gt;, &lt;code&gt;instance()&lt;/code&gt; and their &lt;code&gt;*If&lt;/code&gt; forms, and the &lt;code&gt;$bindings&lt;/code&gt; and &lt;code&gt;$singletons&lt;/code&gt; arrays. The bound class can be &lt;code&gt;X::class&lt;/code&gt;, &lt;code&gt;new X&lt;/code&gt;, or a closure that returns one:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'steam'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Steam&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Steam&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A key bound nowhere, or bound to two different classes, is not guessed. &lt;code&gt;phpgraph overview&lt;/code&gt; lists the facades it could not follow, with the reason.&lt;/p&gt;

&lt;p&gt;Here is the same question, asked of phpgraph:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ phpgraph impact 'ThemeService::dispatch'
Impact of changing ThemeService::dispatch() [method], app/Theming/ThemeService.php L53
73 classes up to 3 relations away, 146 routes; 58 tests

Routes reaching it, ← from their handler:
  POST /register ← RegisterController::postRegister() ← LoginService::login()
  POST /oidc/login ← OidcController::login() ← OidcService::login()
  POST /books ← BookController::store() ← ActivityLogger::add()
  PUT /books/{bookSlug}/sort ← BookSortController::update() ← ActivityLogger::add()
  ...

Direct dependents:
  LoginService (BookStack\Access): login L53; ...
  RegistrationService (BookStack\Access): registerUser L91, L106; ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's 73 classes instead of 1, every route that ends up running the method, and the 58 tests to run before you push. The chains go through the job (&lt;code&gt;DispatchWebhookJob&lt;/code&gt;) the activity logger dispatches, because phpgraph links jobs and events to their handlers too.&lt;/p&gt;

&lt;p&gt;On &lt;a href="https://github.com/firefly-iii/firefly-iii" rel="noopener noreferrer"&gt;Firefly III&lt;/a&gt;, which has 11 facades bound by string keys, this adds 1,289 resolved calls. &lt;code&gt;impact&lt;/code&gt; of &lt;code&gt;Steam::bcround()&lt;/code&gt; went from 0 classes to 91.&lt;/p&gt;

&lt;h2&gt;
  
  
  Eloquent relations
&lt;/h2&gt;

&lt;p&gt;The second Laravel change in 2.4.0 is about models. A relation method is now an edge of the graph:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;HasMany&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;hasMany&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Page&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;gives &lt;code&gt;Book::pages() relates_to Page&lt;/code&gt;. phpgraph's &lt;code&gt;outline&lt;/code&gt; command answers "how does this feature work?" with the classes involved, the routes running into them and the tests. Before 2.4.0, &lt;code&gt;outline "Book"&lt;/code&gt; folded Page, Chapter and Bookshelf into a family line ("Entity: 5"), because they all extend &lt;code&gt;Entity&lt;/code&gt;. Now it names them, with the relation that brought each one in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Core, by namespace:
  BookStack\Entities\Models [Entities]
    Book (class) [seed]
    Bookshelf (class, implements HasDescriptionInterface, HasCoverInterface) [belongsToMany by Book::shelves]
    Page (class) [hasMany by Book::pages]
    Chapter (class, implements HasDescriptionInterface, HasDefaultTemplateInterface) [hasMany by Book::chapters]
    SortRule (class) [belongsTo by Book::sortRule]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Polymorphic relations (&lt;code&gt;morphMany&lt;/code&gt; for comments, tags, views…) are left out on purpose: they link a model to every other model that can be commented on, which says nothing about the feature.&lt;/p&gt;

&lt;p&gt;Casts, timestamps and relations read as properties were already typed, so &lt;code&gt;$page-&amp;gt;book-&amp;gt;chapters()&lt;/code&gt; resolves through the whole chain.&lt;/p&gt;

&lt;h2&gt;
  
  
  What else it reads in a Laravel app
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Events, jobs and listeners:&lt;/strong&gt; &lt;code&gt;$listen&lt;/code&gt;, &lt;code&gt;Event::listen()&lt;/code&gt;, subscribers, listeners of a union of events, &lt;code&gt;event()&lt;/code&gt;, &lt;code&gt;dispatch()&lt;/code&gt;, &lt;code&gt;Job::dispatch()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Routes:&lt;/strong&gt; route files, groups with &lt;code&gt;prefix&lt;/code&gt;, &lt;code&gt;domain&lt;/code&gt; and &lt;code&gt;name&lt;/code&gt;, resources, &lt;code&gt;Route::view&lt;/code&gt; and &lt;code&gt;redirect&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The HTTP client:&lt;/strong&gt; &lt;code&gt;Http::&lt;/code&gt; calls linked to the routes they reach, relative to their &lt;code&gt;baseUrl()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The container:&lt;/strong&gt; &lt;code&gt;app(X::class)&lt;/code&gt; and &lt;code&gt;app()-&amp;gt;make(X::class)&lt;/code&gt; give an &lt;code&gt;X&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  And Laravel Boost?
&lt;/h2&gt;

&lt;p&gt;If you use &lt;a href="https://laravel.com/docs/master/boost" rel="noopener noreferrer"&gt;Laravel Boost&lt;/a&gt;, the two fit together. Boost tells the agent about the running application: routes, database schema, logs, the docs for your versions, Tinker. phpgraph tells it what calls what, and what a change reaches, without booting anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Blade and Twig templates are not read: a call written in a view is not in the graph.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;when()-&amp;gt;needs()-&amp;gt;give()&lt;/code&gt; is not used. When an interface has several implementations, &lt;code&gt;impact&lt;/code&gt; lists the callers of each.&lt;/li&gt;
&lt;li&gt;A facade bound by code phpgraph can't read is reported, not guessed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full list is in &lt;a href="https://github.com/alpine-ronin/phpgraph/blob/main/docs/LIMITATIONS.md" rel="noopener noreferrer"&gt;docs/LIMITATIONS.md&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trying it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -fsSL https://raw.githubusercontent.com/alpine-ronin/phpgraph/main/install.sh &lt;span class="o"&gt;|&lt;/span&gt; sh
&lt;span class="nb"&gt;cd&lt;/span&gt; your-laravel-app
phpgraph mcp-config claude   &lt;span class="c"&gt;# or codex, cursor, json&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's a single binary that needs no PHP, and there is also a PHAR, a Composer package and a Docker image. The graph builds on first use and rebuilds itself when the code changes. It's MIT licensed.&lt;/p&gt;

&lt;p&gt;If you try it on your app and a facade, a binding or a relation isn't followed, open an issue with the snippet. Several of the Laravel fixes so far started that way.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>ai</category>
      <category>mcp</category>
    </item>
  </channel>
</rss>
