Error on php artisan:optimize
I get the following error when running php artisan:optimize
in production.
TypeError: Livewire\Volt\FragmentAlias::encode(): Argument #2 ($path) must be of type string, null given, called in /home/deployer/claimzap.app/releases/3/vendor/livewire/volt/src/Precompilers/ExtractFragments.php on line 96
Anyone else experiencing this?
Hi there,
I've not seen this before. The only reference that I can find after a quick Google search is this thread here:
Are you using the spatie/laravel-csp
package?
After more searching I found this thread: https://github.com/livewire/volt/issues/118#issuecomment-2405898921
The user said he solved it when he says "issue was caused by other package during updates when variable was not used in template: imanghafoori1/laravel-microscope"
On that page it links to using the php artisan check:views
command in Laravel microscope. When I run that command I get:
Checking views...
./composer.json
➖ PSR-4
➖ App\: ./app/ ( 86 files )
➖ Database\Factories\: ./database/factories/ ( 2 files )
➖ Database\Seeders\: ./database/seeders/ ( 21 files )
➖ Wave\: ./wave/src/ ( 62 files )
➖ Tests\: ./tests/ ( 7 files )
1 The blade file is missing:
theme::home.blade.php does not exist
at wave/src/Http/Controllers/HomeController.php:33
______________________________________________________________________________________________________________________________________________________________________________________________________
2 The blade file is missing:
theme::profile.blade.php does not exist
at wave/src/Http/Controllers/ProfileController.php:11
______________________________________________________________________________________________________________________________________________________________________________________________________
3 The blade file is missing:
theme::settings/index.blade.php does not exist
at wave/src/Http/Controllers/SettingsController.php:20
______________________________________________________________________________________________________________________________________________________________________________________________________
time: 0.088 (sec)
- 38 view references were checked to exist. (0 skipped)
Do you think this could be causing the problem? These missing blade templates?
Hey!
I think that those controllers can just be deleted, they are not used in Wave v3.
I've prepared a PR for that:
https://github.com/thedevdojo/wave/pull/237
But you can just delete them locally.
On a fresh new Wave install the optimize command works and those controllers are present so it is likely that this is not the issue but maybe some of the packages that you've installed.
When I try to run it locally I get a little more info on the error:
% php artisan optimize
INFO Caching framework bootstrap, configuration, and metadata.
config ............................................................................................................................. 141.75ms DONE
events ............................................................................................................................... 0.92ms DONE
routes ............................................................................................................................. 146.37ms DONE
views ............................................................................................................................... 13.53ms FAIL
TypeError
Livewire\Volt\FragmentAlias::encode(): Argument #2 ($path) must be of type string, null given, called in /Users/alex/Herd/claimzap/vendor/livewire/volt/src/Precompilers/ExtractFragments.php on line 96
at vendor/livewire/volt/src/FragmentAlias.php:15
11▕
12▕ /**
13▕ * Encode the given fragment's component name and path into a base64 embedded alias.
14▕ */
➜ 15▕ public static function encode(string $componentName, string $path, ?string $basePath = null): string
16▕ {
17▕ $basePath = $basePath ?? static::$basePath ?? base_path();
18▕
19▕ return 'volt-anonymous-fragment-'.base64_encode(json_encode([
+2 vendor frames
3 [internal]:0
Livewire\Volt\Precompilers\ExtractFragments::{closure:Livewire\Volt\Precompilers\ExtractFragments::__invoke():36}()
+5 vendor frames
9 [internal]:0
Illuminate\Foundation\Console\ViewCacheCommand::{closure:Illuminate\Foundation\Console\ViewCacheCommand::compileViews():61}(Object(Symfony\Component\Finder\SplFileInfo), "/Users/alex/Herd/claimzap/resources/views/filament/pages/media.blade.php")
What could be going on with the media.blade.php that could cause this? I have not edited it.
Hey!
The media file is there on a default install and it does not cause issues so sounds like it might be something else. You could try temporary removing that media file and testing again to see if it is indeed the issue.
One thing that you could also check is the Livewire, and Volt versions are compatible. This might be fixed in newer versions of Volt or maybe a bug in newer versions:
composer show livewire/livewire
composer show livewire/volt
Run those and share the output so I can compare them with mine and see if this is the case!
composer show livewire/livewire
name : livewire/livewire
descrip. : A front-end framework for Laravel.
keywords :
versions : * v3.6.3
released : 2025-04-12, 1 month ago
type : library
license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage :
source : [git] https://github.com/livewire/livewire.git 56aa1bb63a46e06181c56fa64717a7287e19115e
dist : [zip] https://api.github.com/repos/livewire/livewire/zipball/56aa1bb63a46e06181c56fa64717a7287e19115e 56aa1bb63a46e06181c56fa64717a7287e19115e
path : /Users/alex/Herd/claimzap/vendor/livewire/livewire
names : livewire/livewire
support
issues : https://github.com/livewire/livewire/issues
source : https://github.com/livewire/livewire/tree/v3.6.3
autoload
files
psr-4
Livewire\ => src/
requires
illuminate/database ^10.0|^11.0|^12.0
illuminate/routing ^10.0|^11.0|^12.0
illuminate/support ^10.0|^11.0|^12.0
illuminate/validation ^10.0|^11.0|^12.0
laravel/prompts ^0.1.24|^0.2|^0.3
league/mime-type-detection ^1.9
php ^8.1
symfony/console ^6.0|^7.0
symfony/http-kernel ^6.2|^7.0
requires (dev)
calebporzio/sushi ^2.1
laravel/framework ^10.15.0|^11.0|^12.0
mockery/mockery ^1.3.1
orchestra/testbench ^8.21.0|^9.0|^10.0
orchestra/testbench-dusk ^8.24|^9.1|^10.0
phpunit/phpunit ^10.4|^11.5
psy/psysh ^0.11.22|^0.12
alex@Mac claimzap % composer show livewire/volt
name : livewire/volt
descrip. : An elegantly crafted functional API for Laravel Livewire.
keywords : laravel, livewire, volt
versions : * v1.7.1
released : 2025-04-08, 1 month ago
type : library
license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage : https://github.com/livewire/volt
source : [git] https://github.com/livewire/volt.git ba3e609fd4c71f8b5783f024baf51715e48e93a6
dist : [zip] https://api.github.com/repos/livewire/volt/zipball/ba3e609fd4c71f8b5783f024baf51715e48e93a6 ba3e609fd4c71f8b5783f024baf51715e48e93a6
path : /Users/alex/Herd/claimzap/vendor/livewire/volt
names : livewire/volt
support
issues : https://github.com/livewire/volt/issues
source : https://github.com/livewire/volt
autoload
files
psr-4
Livewire\Volt\ => src/
requires
laravel/framework ^10.38.2|^11.0|^12.0
livewire/livewire ^3.6.1
php ^8.1
requires (dev)
laravel/folio ^1.1
mockery/mockery ^1.6
orchestra/testbench ^8.15.0|^9.0|^10.0
pestphp/pest ^2.9.5|^3.0
phpstan/phpstan ^1.10
I tried with those versions too and it seem to all work as expected still:
php artisan optimize
INFO Caching framework bootstrap, configuration, and metadata.
config ............................................... 13.81ms DONE
events ................................................ 0.80ms DONE
routes ............................................... 14.31ms DONE
views ............................................... 370.88ms DONE
blade-icons ......................................... 117.31ms DONE
filament ............................................ 113.61ms DONE
Ugh what the heck. Maybe another package I have is causing an issue. Here is my entire composer file, can you try these additional packages?
{
"name": "devdojo/wave",
"description": "Wave SaaS Starter Kit",
"keywords": ["framework", "laravel", "SaaS", "Starter Kit"],
"license": "MIT",
"type": "project",
"require": {
"php": "^8.1",
"ext-exif": "*",
"ext-gd": "*",
"ext-imagick": "*",
"ext-zip": "*",
"bezhansalleh/filament-google-analytics": "^2.0",
"codeat3/blade-phosphor-icons": "^2.0",
"devdojo/app": "0.11.0",
"devdojo/auth": "^1.0",
"devdojo/themes": "0.0.11",
"filament/filament": "^3.2",
"gehrisandro/tailwind-merge-laravel": "^1.2",
"guzzlehttp/guzzle": "^7.2",
"intervention/image": "^2.7",
"lab404/laravel-impersonate": "^1.7.5",
"laravel/folio": "^1.1",
"laravel/framework": "^11.0",
"laravel/horizon": "^5.31",
"laravel/pail": "^1.2",
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.7",
"laravel/ui": "^4.5",
"livewire/livewire": "^3.0",
"phpseclib/phpseclib": "~3.0",
"ralphjsmit/livewire-urls": "^1.4",
"sentry/sentry-laravel": "^4.13",
"spatie/laravel-backup": "^9.3",
"spatie/laravel-permission": "^6.4",
"stripe/stripe-php": "^15.3",
"tymon/jwt-auth": "@dev"
},
"require-dev": {
"alebatistella/duskapiconf": "^1.2",
"barryvdh/laravel-debugbar": "^3.15",
"deployer/deployer": "^7.5",
"fakerphp/faker": "^1.9.1",
"imanghafoori/laravel-microscope": "^1.0",
"laravel/dusk": "^8.0",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "6.4.0|^7.0|^8.1",
"pestphp/pest": "^3.4",
"pestphp/pest-plugin-laravel": "^3.0",
"phpunit/phpunit": "^11.0",
"spatie/laravel-ignition": "^2.0"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/",
"Wave\\": "wave/src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [],
"providers": [
"Wave\\WaveServiceProvider"
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi",
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
"@php artisan migrate --graceful --ansi",
"@php artisan db:seed"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover",
"@php artisan storage:link",
"@php artisan filament:upgrade",
"@php artisan livewire:publish --assets"
],
"dev": [
"Composer\\Config::disableProcessTimeout",
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
}