NativePHP / laravel

Laravel wrapper for the NativePHP framework
https://nativephp.com
MIT License
3.17k stars 164 forks source link

[Bug]: Missing commands, native:config and native:php-ini #168

Closed adammpkins closed 6 months ago

adammpkins commented 1 year ago

What happened?

When I install a fresh application and require NativePHP, and attempt to bring it up with native:serve, I get an error in the output stating

Error: Command failed: /home/adammpkins/Development/NativePHP/vendor/nativephp/electron/resources/js/resources/php/php artisan native:config

    at ChildProcess.exithandler (node:child_process:430:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1091:16)
    at Socket.<anonymous> (node:internal/child_process:449:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:322:12) {
  code: 1,
  killed: false,
  signal: null,
  cmd: '/home/adammpkins/Development/NativePHP/vendor/nativephp/electron/resources/js/resources/php/php artisan native:config',
  stdout: '\n' +
    '   ERROR  Command "native:config" is not defined. Did you mean one of these?  \n' +
    '\n' +
    '  ⇂ native:build  \n' +
    '  ⇂ native:install  \n' +
    '  ⇂ native:migrate  \n' +
    '  ⇂ native:minify  \n' +
    '  ⇂ native:publish  \n' +
    '  ⇂ native:queue  \n' +
    '  ⇂ native:serve  \n' +
    '\n',
  stderr: ''
}

I see commands for LoadPHPConfigurationCommand and LoadStartupConfigurationCommand but the application doesn't seem to see them.

How to reproduce the bug

Install Laravel via

curl -s "https://laravel.build/NativePHP" | bash

require nativephp via

composer require nativephp/electron

Attempt to bring the application up with

php artisan native:serve

Package Version

0.4.0

PHP Version

8.2.0

Laravel Version

10

Node Version

20.3.1

Which operating systems does with happen with?

Linux

Notes

No response

JayBizzle commented 1 year ago

Seems related to this commit - https://github.com/NativePHP/laravel/commit/6a4357518a93f73bc8a80fb0a69996b8a9e6470b

if (config('nativephp-internal.running')) {

...always seems to be false

Jonnx commented 1 year ago

+1 on intel mac

mhoffmann777 commented 1 year ago

Same for all commands in vendor/nativephp/laravel/src/Commands/

On M1 MacBookPro

PriceNathan commented 1 year ago

db:seed also doesn't work

valpuia604 commented 1 year ago

Same as #160.

keenminded commented 1 year ago

Please take a look at my comment in https://github.com/NativePHP/laravel/issues/160#issuecomment-1685349569

danielpetrica commented 1 year ago

A workaround which seems to work for me is adding this environment variable

NATIVEPHP_RUNNING=true

ralphmorris commented 1 year ago

+1 on this. Mac Pro M1

ricvillagrana commented 1 year ago

+1 for Intel.

hussainweb commented 1 year ago

The fix is present in the HEAD of https://github.com/NativePHP/electron-plugin (see file) but it is not tagged. The current version of nativephp/electron package is locked to version 0.2.0 of that plugin. There is a version 0.3.0 of the plugin but the fix was made after that. I can't figure out how to install untagged releases of npm packages so I can't try the latest HEAD release.

It looks like we have to wait for the next version of the plugin and then corresponding updates to the lock file in nativephp/electron. Meanwhile, I got it working by adding the environment variable manually to php.js in the retrieveNativePHPConfig function (lines 40-42):

        const env = {
            NATIVEPHP_STORAGE_PATH: storagePath,
            NATIVEPHP_DATABASE_PATH: databaseFile,
            NATIVEPHP_RUNNING: true,
        };
ThibautPV commented 10 months ago

Same problem on Mac M2

I try to add "NATIVEPHP_RUNNING: true,", without success. Always the same problem.

Error :


Error: Command failed: /Users/***/***/***/nativephptest/vendor/nativephp/electron/resources/js/resources/php/php artisan native:config

    at ChildProcess.exithandler (node:child_process:430:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1091:16)
    at ChildProcess._handle.onexit (node:internal/child_process:302:5) {
  code: 255,
  killed: false,
  signal: null,
  cmd: '/Users/***/***/***/nativephptest/vendor/nativephp/electron/resources/js/resources/php/php artisan native:config',
  stdout: '\n' +
    'Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.2.0". You are running 8.1.17. in /Users/***/***/***/nativephptest/vendor/composer/platform_check.php on line 24\n',
  stderr: ''
}
nickpoulos commented 9 months ago

Has there been any progress or workarounds found for this issue? 🙏

It is kind of a deal breaker for experimenting with NativePHP.

simonhamp commented 9 months ago

'Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.2.0". You are running 8.1.17. in /Users///***/nativephptest/vendor/composer/platform_check.php on line 24\n'

@ThibautPV your issue is different. It seems you've installed your Composer dependencies under PHP8.2 while NativePHP currently uses PHP8.1.

This can be fixed by running composer install with PHP8.1.

Alternatively, the version of PHP inside NativePHP needs to match your system. More PHP versions are coming soon.

simonhamp commented 9 months ago

@nickpoulos which issue are you experiencing? There seem to be multiple ones referenced here

omitobi commented 6 months ago

Before: Trying to run it on PHP 8.2, I got this same error.

Running it on PHP 8.1 fixes this issue for me.

simonhamp commented 6 months ago

The issue with the missing NATIVEPHP_RUNNING environment variable should be solved.

Please update to nativephp/electron v0.6 and try again.