Skip to content

I have issues compiling locally when I disable the updater. #518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JhoanSteve opened this issue Mar 17, 2025 · 3 comments
Open

I have issues compiling locally when I disable the updater. #518

JhoanSteve opened this issue Mar 17, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@JhoanSteve
Copy link

JhoanSteve commented Mar 17, 2025

What were you trying to do?

define my local management project with .env:

NATIVEPHP_APP_VERSION="1.0.0"
NATIVEPHP_APP_ID="com.netziweb.history"
NATIVEPHP_DEEPLINK_SCHEME="nativephp"
NATIVEPHP_APP_AUTHOR="NetziWeb"
NATIVEPHP_UPDATER_ENABLED=false
NATIVEPHP_UPDATER_PROVIDER=
NATIVEPHP_UPDATER_URL=


but to execute it php artisan native:publish generates this in file vendor/nativephp/electron/src/Updater/UpdaterManager.php:71 : NativePHP updater provider [] is not defined.

 
$config = $this->getConfig($name);

if (is_null($config)) {
throw new InvalidArgumentException("NativePHP updater provider [{$name}] is not defined."); //error generate
}

$driverMethod = 'create'.ucfirst($config['driver']).'Driver';

What happened?

You will also eliminate NATIVEPHP_UPDATER_PROVIDER and NATIVEPHP_UPDATER_URL from .env but continue with the same problem.

Also envied in NATIVEPHP_UPDATER_PROVIDER as empty or null but generates the same problem.
NativePHP updater provider [{$name}] is not defined.

How to reproduce the bug

I am using php 8.3.6, Ubuntu 24.04.2 LTS, y laravel 12.0, "nativephp/electron": "^1.0@beta" , sqlite 3, npm 10.8.2, node v20.18.3

Package Versions

jhoan@jhoan:~/code/clinicHistory.com$ composer show "nativephp/*" --format=json

{
    "installed": [
        {
            "name": "nativephp/electron",
            "direct-dependency": true,
            "homepage": "https://github.com/nativephp/electron",
            "source": "https://github.com/NativePHP/electron/tree/1.0.0-beta.4",
            "version": "1.0.0-beta.4",
            "description": "Electron wrapper for the NativePHP framework.",
            "abandoned": false
        },
        {
            "name": "nativephp/laravel",
            "direct-dependency": false,
            "homepage": "https://github.com/nativephp/laravel",
            "source": "https://github.com/NativePHP/laravel/tree/1.0.0-beta.2",
            "version": "dev-main 0102a92",
            "description": "Laravel wrapper for the NativePHP framework.",
            "abandoned": false
        },
        {
            "name": "nativephp/php-bin",
            "direct-dependency": false,
            "homepage": "https://nativephp.com",
            "source": "https://github.com/NativePHP/php-bin/tree/0.5.6",
            "version": "0.5.6",
            "description": "PHP binaries used by the NativePHP framework",
            "abandoned": false
        }
    ]
}

PHP Version

8.3.6

Laravel Version

12.0

Node Version

v20.18.3

Which operating systems have you seen this occur on?

Ubuntu

OS version

24.04.2

Notes

No response

@JhoanSteve JhoanSteve added the bug Something isn't working label Mar 17, 2025
@simonhamp
Copy link
Member

I think a fix for that makes sense. If you're up for making a PR that would be greatly appreciated 👍🏼

@simonhamp simonhamp changed the title Problems when sending php artisan native:publish Exception when disabling auto-update Mar 18, 2025
@JhoanSteve JhoanSteve changed the title Exception when disabling auto-update I have issues compiling locally when I disable the updater. Mar 18, 2025
@JhoanSteve
Copy link
Author

JhoanSteve commented Mar 18, 2025

🚀 Fix: php artisan native:publish fails when no provider is specified

🛑 Problem

Currently, running php artisan native:publish without specifying a provider results in an error:

if (is_null($config)) {
            throw new InvalidArgumentException("NativePHP updater provider [{$name}] is not defined.");
}

🔍 Cause

The command requires a provider explicitly, but in some cases, it should be able to run without one.

✅ Solution

To resolve this, I implemented a NullUpdaterProvider and added support for it in UpdaterManager.php.

1️⃣ Create the file NullUpdaterProvider.php

Path: vendor/nativephp/electron/src/Updater/NullUpdaterProvider.php

<?php

namespace Native\Electron\Updater;

use Native\Electron\Updater\Contracts\Updater;

class NullUpdaterProvider implements Updater
{
    public function builderOptions(): array
    {
        return [];
    }

    public function checkForUpdates(): ?array
    {
        return null;
    }

    public function downloadUpdate(): ?bool
    {
        return false;
    }

    public function installUpdate(): ?bool
    {
        return false;
    }

    public function environmentVariables(): array
    {
        return [];
    }
}

2️⃣ Modify the file UpdaterManager.php

Path: vendor/nativephp/electron/src/Updater/UpdaterManager.php
add the following code

/**
 * Create an instance of the null updater driver.
 *
 * @return \Native\Electron\Updater\Contracts\Updater
 */
protected function createNullDriver()
{
    return new NullUpdaterProvider();
}

This is a correction for the "NativePHP/electron" project, but since I can't report the issue, I'm transcribing it here.

Well, that would be all to compile a project without vendors. ✅✅

If you consider my solution, I hope you can mention me in the project. That would help me with my portfolio. Thank you!

@simonhamp
Copy link
Member

Please can you PR this to the nativephp/electron repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants