What seems to be the problem:
My application was running perfectly passing each test and running in the browser.
After upgrading my application according to this screencast:
https://laravel-livewire.com/screencasts/s6-bind-to-models
Especially the “type-hinting” at 1:42 (which made me upgrade my php version from 7.3 to 7.4 inside my composer.json (after I ran composer update and composer install)) (I did that because it was suggested by php storm) - no idea what the result is of upgrading php inside the composer.json file and than runnin update and install … I did it anyways because … why not? php storm will know what to do
"php": "^7.3|^8.0", -> to "php": "^7.4",
I am now getting the error:
This driver does not support creating temporary URLs.
Now I went back to my last commit where everything used to work and things still blow up.
I mean I also revered to the original
"php": "^7.3|^8.0", -> to "php": "^7.4",
So something must have gone crazy in the “userland” I guess.
Other people are experiencing similar issues.
https://github.com/livewire/livewire/issues/1106
Does anyone have an idea where to start?
Steps to Reproduce:
Just follow the screencast or check my code examples below
Are you using the latest version of Livewire:
Yes.
Do you have any screenshots or code examples:
this is my livewire “profile.blade.php” if I remove the temporaryUrl method the test passes and the browser works.
<x-input.filepond wire:model="files" multiple/>
<div >
@foreach($files as $file)
<img src="{{ $file->temporaryUrl() }}">
@endforeach
</div >
this is my livewire model “profile.php”
<?php
namespace App\Http\Livewire;
use App\Models\User;
use Livewire\Component;
use Livewire\WithFileUploads;
class Profile extends Component
{
// protected $listeners = ['notify-saved'];
use WithFileUploads;
public User $user;
public $upload;
public $files = [];
protected $rules = [
'user.about' => 'max:140|nullable',
'upload' => 'image|max:20000|nullable'
];
public function mount()
{
$this->user = auth()->user();
}
public function updatedAbout()
{
$this->validateOnly('about');
}
public function updatedNewAvatar()
{
$this->validate([
'upload' => 'image|max:20000'
]);
}
public function save()
{
$this->validate();
$this->user->save();
$this->upload && $this->user->update([
'avatar' => $this->upload->store('/', 'avatars'),
]);
$this->emitSelf('notify-saved');
}
}
This is my test
/** @test */
public function can_upload_avatar()
{
$user = User::factory()->create();
$file = UploadedFile::fake()->image('photo1.jpg');
Storage::fake('avatars');
Livewire::actingAs($user)
->test('profile')
->set('upload', $file)
->call('save');
$user->refresh();
$this->assertNotNull($user->avatar);
Storage::disk('avatars')->assertExists($user->avatar);
}
and the results:
this is my disk
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'avatars' => [
'driver' => 'local',
'root' => storage_path('app/avatars'),
'url' => env('APP_URL').'/avatars',
'visibility' => 'public',
],
this is my livewire config
'temporary_file_upload' => [
'disk' => null, // Example: 'local', 's3' Default: 'default'
'rules' => null, // Example: ['file', 'mimes:png,jpg'] Default: ['required', 'file', 'max:12288'] (12MB)
'directory' => null, // Example: 'tmp' Default 'livewire-tmp'
'middleware' => null, // Example: 'throttle:5,1' Default: 'throttle:60,1'
'preview_mimes' => [ // Supported file types for temporary pre-signed file URLs.
'png', 'gif', 'bmp', 'svg', 'wav', 'mp4',
'mov', 'avi', 'wmv', 'mp3', 'm4a',
'jpeg', 'mpga', 'webp', 'wma'
],
],
this is my composer.json
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "7.4",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.12",
"laravel/tinker": "^2.5",
"livewire/livewire": "^2.3"
},
"require-dev": {
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}
WHILE WRITING THIS ARTICLE I FOUND THE FOLLOWING