-
-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
What were you trying to do?
Trying to get a list of Printers.
What happened?
It throws an exception
How to reproduce the bug
Install a brand new Livewire starter kit, install Nativephp desktop v2, and try System::printers() on mac os (I presume. I haven't tested it on other devices, but I doubt it's broken on everything, as you probably would have caught it then).
Debug Output
{
"Environment": {
"PHP": {
"Version": "8.3.26",
"Path": "/Users/japseyz/Library/Application Support/Herd/bin/php83"
},
"Laravel": {
"Version": "12.34.0",
"ConfigCached": false,
"RoutesCached": false,
"DebugEnabled": true
},
"Node": {
"Version": "v24.6.0",
"Path": "/opt/homebrew/bin/node"
},
"NPM": {
"Version": "11.5.1",
"Path": "/opt/homebrew/bin/npm"
},
"OperatingSystem": "Darwin"
},
"NativePHP": {
"Versions": {
"nativephp/desktop": "2.0.1.0",
"nativephp/php-bin": "1.1.1.0"
},
"Configuration": {
"Provider": "App\Providers\NativeAppServiceProvider",
"BuildHooks": {
"Pre": [
"npm run build",
"php artisan optimize"
],
"Post": [
"rm -rf public/build"
]
},
"NotarizationEnabled": false,
"AzureTrustedSigningEnabled": false,
"CustomPHPBinary": false
}
}
}Which operating systems have you seen this occur on?
macOS
Notes
Note: The System::printers() command worked on my machine in V1.
TypeError
Native\Desktop\DataObjects\Printer::__construct(): Argument #4 ($status) must be of type int, null given, called in /Users/japseyz/Code/PHP/desktop2/vendor/nativephp/desktop/src/System.php on line 54
TypeError
Native\Desktop\DataObjects\Printer::__construct(): Argument #5 ($isDefault) must be of type bool, null given, called in /Users/japseyz/Code/PHP/desktop2/vendor/nativephp/desktop/src/System.php on line 54
I can get it work by providing defaults.
public function printers(): array
{
$printers = $this->client->get('system/printers')->json('printers');
return collect($printers)->map(function ($printer) {
return new Printer(
data_get($printer, 'name'),
data_get($printer, 'displayName'),
data_get($printer, 'description'),
data_get($printer, 'status', 0),
data_get($printer, 'isDefault', 0),
data_get($printer, 'options'),
);
})->toArray();
}Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working