<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>php-tips.com</title>
    <link>https://php-tips.com/en/</link>
    <description>Recent content on php-tips.com</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Fri, 10 Apr 2026 20:47:25 +0900</lastBuildDate>
    <atom:link href="https://php-tips.com/en/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Create Project-Specific PHPStan and PHPCS Rules with AI Agents</title>
      <link>https://php-tips.com/en/2026/04/10/custom-phpstan-phpcs-rules-with-agent/</link>
      <pubDate>Fri, 10 Apr 2026 20:47:25 +0900</pubDate>
      <guid>https://php-tips.com/en/2026/04/10/custom-phpstan-phpcs-rules-with-agent/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt;
Writing rules for AI agents helps, but AI is non-deterministic — violations will slip through.
Enforce project-specific constraints with custom PHPStan/PHPCS rules for mechanical checking.
Let an AI agent draft the custom rules for you, and you can implement them quickly.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;claudemd-alone-isnt-enough&#34;&gt;CLAUDE.md Alone Isn&amp;rsquo;t Enough&lt;/h2&gt;
&lt;p&gt;If you&amp;rsquo;re using an AI agent like Claude Code, you probably write project rules in &lt;code&gt;CLAUDE.md&lt;/code&gt; or rule files. Things like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&amp;ldquo;Use &amp;lsquo;Plan&amp;rsquo; instead of the old term &amp;lsquo;Course&amp;rsquo; everywhere in the code&amp;rdquo;&lt;/li&gt;
&lt;li&gt;&amp;ldquo;&lt;code&gt;DateTime::createFromTimestamp()&lt;/code&gt; must always receive a timezone as the second argument&amp;rdquo;&lt;/li&gt;
&lt;li&gt;&amp;ldquo;Core domain classes must not call infrastructure directly&amp;rdquo;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The agent respects these rules and writes compliant code — most of the time. But AI is non-deterministic. The same instruction doesn&amp;rsquo;t always produce the same output. When the context gets long or the agent is in the middle of a complex refactoring, it can &amp;ldquo;accidentally&amp;rdquo; generate code that violates the rules, even though they&amp;rsquo;re written right there in the rule files.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Reduce Node.js Docker Image Size with Multi-Stage Builds</title>
      <link>https://php-tips.com/en/2026/04/01/docker-multistage-build-nodejs/</link>
      <pubDate>Wed, 01 Apr 2026 20:32:55 +0900</pubDate>
      <guid>https://php-tips.com/en/2026/04/01/docker-multistage-build-nodejs/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; Use Docker multi-stage builds to separate &amp;ldquo;build&amp;rdquo; and &amp;ldquo;production&amp;rdquo; stages in your Dockerfile. Dev dependencies and build tools stay out of the final image. In one of my projects, this cut the image size from nearly 2 GB down to under 1 GB.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;why-smaller-images-matter&#34;&gt;Why Smaller Images Matter&lt;/h2&gt;
&lt;p&gt;Keeping your Docker image small has real benefits:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Faster deployments&lt;/strong&gt; — Smaller images mean faster pulls, which speeds up CI/CD pipelines and auto-scaling container startups&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lower storage costs&lt;/strong&gt; — Less registry storage (ECR, GCR, etc.) and less data transfer&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reduced security risk&lt;/strong&gt; — Fewer packages and tools in the image means a smaller attack surface&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;the-problem-dev-dependencies-bloat-your-image&#34;&gt;The Problem: Dev Dependencies Bloat Your Image&lt;/h2&gt;
&lt;p&gt;When building a Node.js app with Docker, you might write a single-stage Dockerfile like this:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Teach Claude Code Your Available UNIX Commands to Boost Efficiency</title>
      <link>https://php-tips.com/en/2026/03/30/claude-code-unix-commands-rules/</link>
      <pubDate>Mon, 30 Mar 2026 08:01:11 +0900</pubDate>
      <guid>https://php-tips.com/en/2026/03/30/claude-code-unix-commands-rules/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; Tell Claude Code about your installed commands (&lt;code&gt;rg&lt;/code&gt;, &lt;code&gt;fd&lt;/code&gt;, &lt;code&gt;jq&lt;/code&gt;, etc.) via a user rule file (&lt;code&gt;~/.claude/rules/&lt;/code&gt;), and it&amp;rsquo;ll automatically prefer &lt;code&gt;rg&lt;/code&gt; over &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;fd&lt;/code&gt; over &lt;code&gt;find&lt;/code&gt;, and so on. One prompt does the whole inventory.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;background&#34;&gt;Background&lt;/h2&gt;
&lt;p&gt;Claude Code knows basic UNIX commands like &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;find&lt;/code&gt;, and &lt;code&gt;cat&lt;/code&gt;, but it doesn&amp;rsquo;t know whether your machine has &lt;code&gt;rg&lt;/code&gt; (ripgrep) or &lt;code&gt;fd&lt;/code&gt; installed.&lt;/p&gt;
&lt;p&gt;So even though you have faster tools available, Claude Code ends up using &lt;code&gt;grep&lt;/code&gt; every time, or runs &lt;code&gt;which rg&lt;/code&gt; to check before using it. A bit wasteful, right?&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to Get macOS Notifications When Claude Code Is Waiting for Input</title>
      <link>https://php-tips.com/en/2026/03/28/claude-code-notification-macos/</link>
      <pubDate>Sat, 28 Mar 2026 00:52:22 +0900</pubDate>
      <guid>https://php-tips.com/en/2026/03/28/claude-code-notification-macos/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; Set up a Claude Code hook to get macOS desktop notifications with sound and speech when Claude Code finishes a task or waits for input. SAY!!&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;background&#34;&gt;Background&lt;/h2&gt;
&lt;p&gt;Claude Code sometimes runs tasks for a while, and you want to know when it&amp;rsquo;s done, right?&lt;/p&gt;
&lt;p&gt;There&amp;rsquo;s an official notification setting, but notifications don&amp;rsquo;t always fire or are easy to miss.&lt;/p&gt;
&lt;p&gt;So let&amp;rsquo;s use a custom hook to get reliable macOS desktop notifications with text-to-speech.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Released CakePHP Plugin - SlugGuard to Prevent User Slug and URL Route Collision</title>
      <link>https://php-tips.com/en/2026/03/27/cakephp-slug-guard/</link>
      <pubDate>Fri, 27 Mar 2026 22:46:24 +0900</pubDate>
      <guid>https://php-tips.com/en/2026/03/27/cakephp-slug-guard/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; I released a CakePHP 5.x plugin that validates user-input URL slugs against reserved words and application routes to prevent collisions.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/elstc/cakephp-slug-guard&#34;&gt;elstc/cakephp-slug-guard: CakePHP plugin for URL-safe slug validation and reserved-word collision prevention&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;hr&gt;
&lt;p&gt;&lt;img alt=&#34;SlugGuard - CakePHP Plugin&#34; loading=&#34;lazy&#34; src=&#34;https://php-tips.com/uploads/2026/03/cakephp-slug-guard-eyecatch.png&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;what-does-this-plugin-do&#34;&gt;What Does This Plugin Do?&lt;/h2&gt;
&lt;p&gt;In web applications, you often want to let users choose their own profile URL slug &amp;ndash; something like &lt;code&gt;example.com/nojimage&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;But if a user registers a slug like &lt;code&gt;admin&lt;/code&gt;, &lt;code&gt;login&lt;/code&gt;, or &lt;code&gt;api&lt;/code&gt;, it collides with your application&amp;rsquo;s routes and causes serious problems.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
