Abdulkader Safi

Shipping LaralCN-UI right to left: a fourth way a deploy can lie to you

After I deployed the right-to-left work, the live LaralCN-UI docs still showed the old pages, with no language switch or theme toggle in the sidebar. PHP-FPM was still running the previous code from OPcache, and the fix was one line at the end of deploy.sh.

5 min read

Share
The LaralCN-UI docs sidebar footer with English and Arabic language links and a theme toggle, the parts that were missing after the broken deploy.

In part 3 I wrote about three ways a deploy can lie to you. On 29 Nov 2026 I found a fourth. The right-to-left PR merged at 13:44, deploy.sh ran without an error, and the live site showed neither the new language switch nor the theme toggle. The cause was OPcache on the VPS, and the fix (commit 3bec70b) took one line.

The deploy finished and the site did not change

The RTL work added a global middleware (LocalePrefix) that strips /ar from the URL before routing, plus a new sidebar footer with the EN and ع links and the theme toggle. After deploying I opened the site and saw the old sidebar, as if the PR had never merged. Yet git pull had worked, and the new files were on disk.

This is the deploy script as it stood:

echo "==> git pull"
git pull origin main

echo "==> composer install (no-dev)"
"$PHP" "$COMPOSER" install --no-dev --optimize-autoloader

echo "==> rebuild caches"
"$PHP" artisan optimize:clear
"$PHP" artisan config:cache
"$PHP" artisan route:cache
"$PHP" artisan view:cache

echo "==> fix ownership for php-fpm (www-data)"
sudo chown -R www-data:www-data storage bootstrap/cache

Every step ran and reported success. The caches were rebuilt from the new code. PHP-FPM ignored all of it.

OPcache was not checking timestamps

PHP compiles each file to bytecode and OPcache keeps that bytecode in shared memory, keyed by file path. With opcache.validate_timestamps on, PHP checks the file's modification time and recompiles when it changes. On this VPS it is off, which is a common production setting because it saves a stat call per file per request. The trade-off is that PHP-FPM never looks at the disk again for a file it has already cached.

Laravel's caches made this worse, because they reuse filenames. route:cache writes the new route table to the same bootstrap/cache file as before. view:cache writes compiled Blade views to storage/framework/views under names derived from the view's path, so the new layout compiled to the same filename as the old one. OPcache saw the same paths it already had and kept serving the old bytecode: the old route list without the middleware, and the old layout without the footer.

The CSS was different because PHP never caches it. Vite writes hashed filenames (app-<hash>.css) and Caddy serves them straight from public/build. The layout reads manifest.json at runtime to find the current hash, and a JSON file read with file_get_contents does not go through OPcache. So the old layout asked the manifest for the stylesheet and got the new one.

The fix is one line

PHP-FPM drops its OPcache when it reloads. A graceful reload lets running requests finish, then starts fresh workers with an empty cache. The deploy script now ends with it:

echo "==> reload php-fpm (drop OPcache)"
# With opcache.validate_timestamps off, php-fpm keeps serving the old compiled
# PHP after a pull: the route cache and compiled views keep their filenames, so
# new routes, middleware and layouts never load. A graceful reload clears it.
sudo systemctl reload php8.4-fpm

The service name is php8.4-fpm because the VPS runs two PHP versions: the default php is 8.3 for another site, and this one runs on 8.4. I reran the deploy, the sidebar footer appeared, and /ar/components/button rendered right to left. DEPLOYMENT.md lists the reload as the last step so the next person reading it knows why it is there.

What made this deploy different

The RTL PR was the first deploy that added PHP every request depends on: a middleware prepended in bootstrap/app.php with $middleware->prepend(\App\Http\Middleware\LocalePrefix::class), and a route table that had to run behind it. A stale layout is easy to miss when the change is a margin. A stale middleware list breaks a whole URL space, which is why this one was impossible to miss.

A fourth way a deploy can lie

Part 3 listed three cases where the deploy said "done" and production disagreed. This one belongs on the same list. Every command exited 0, every cache was rebuilt, the files on disk were correct, and the browser still got the old app. The only check that caught it was opening the live page and looking for a feature I knew should be there. A smoke check that loads one new URL after deploy would have caught it in seconds.

Where it is

composer require --dev safi/laralcn-ui
php artisan ui:init
php artisan ui:add sidebar

The live docs, with the /ar pages working, are at https://laralcn-ui.abdulkadersafi.com. The deploy script and DEPLOYMENT.md are in the repo at https://github.com/Abdulkader-Safi/LaralCN-UI, MIT licensed.

Next: the LaralCN-UI Figma library, where every component was drawn from the Blade code and seven new ones were designed before any code existed.

Last updated 1 Dec 2026 · filed under Laravel, laralcn-ui, hosting

Every entry on this project

26 build notes, in order

Including the ones where nothing worked. You are on part 10.

Read the series →

FAQ

Frequently asked questions

Should I turn opcache.validate_timestamps back on instead?

You can, and stale code goes away at the cost of a file check per request. Keeping it off and reloading PHP-FPM in the deploy script gives you the speed and a known point where new code goes live.

Is systemctl reload safe on a live site?

Yes for PHP-FPM. A reload is graceful: requests in flight finish on the old workers, and new requests go to fresh workers with an empty OPcache.

Does php artisan optimize:clear clear OPcache?

No. It deletes Laravel's cache files on disk, but OPcache lives in PHP-FPM's shared memory, and the CLI process that runs artisan has its own separate cache.

Does this affect apps that use LaralCN-UI components?

Only if they deploy the same way. Any Laravel app on PHP-FPM with validate_timestamps off needs a reload after deploy, whatever components it uses.

Written by

Abdulkader Safi

Software Engineer

Lead engineer at DSRPT, from Lebanon and based in Kuwait. I write about the tools and bugs from real client work, with the numbers I measured.

About me → GitHub LinkedIn

Need this kind of work done on your project?

Start a project →

Keep reading

More from LaralCN-UI: shadcn-style Blade components and blocks you own

All 26 entries →