Skip to content

Commit 430fe14

Browse files
committed
Allow custom php.ini settings
1 parent a547625 commit 430fe14

File tree

4 files changed

+43
-42
lines changed

4 files changed

+43
-42
lines changed

resources/stubs/NativeAppServiceProvider.php.stub

+11-42
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,26 @@
22

33
namespace App\Providers;
44

5-
use Native\Laravel\Facades\ContextMenu;
6-
use Native\Laravel\Facades\Dock;
75
use Native\Laravel\Facades\Window;
8-
use Native\Laravel\Facades\GlobalShortcut;
9-
use Native\Laravel\Menu\Menu;
6+
use Native\Laravel\Contracts\ProvidesPhpIni;
107

11-
class NativeAppServiceProvider
8+
class NativeAppServiceProvider implements ProvidesPhpIni
129
{
1310
/**
1411
* Executed once the native application has been booted.
1512
* Use this method to open windows, register global shortcuts, etc.
1613
*/
1714
public function boot(): void
1815
{
19-
Menu::new()
20-
->appMenu()
21-
->submenu('About', Menu::new()
22-
->link('https://beyondco.de', 'Beyond Code')
23-
->link('https://simonhamp.me', 'Simon Hamp')
24-
)
25-
->submenu('View', Menu::new()
26-
->toggleFullscreen()
27-
->separator()
28-
->link('https://laravel.com', 'Learn More', 'CmdOrCtrl+L')
29-
)
30-
->register();
31-
32-
Window::open()
33-
->width(800)
34-
->height(800);
35-
36-
/**
37-
Dock::menu(
38-
Menu::new()
39-
->event(DockItemClicked::class, 'Settings')
40-
->submenu('Help',
41-
Menu::new()
42-
->event(DockItemClicked::class, 'About')
43-
->event(DockItemClicked::class, 'Learn More…')
44-
)
45-
);
46-
47-
ContextMenu::register(
48-
Menu::new()
49-
->event(ContextMenuClicked::class, 'Do something')
50-
);
16+
Window::open();
17+
}
5118

52-
GlobalShortcut::new()
53-
->key('CmdOrCtrl+Shift+I')
54-
->event(ShortcutPressed::class)
55-
->register();
56-
*/
19+
/**
20+
* Return an array of php.ini directives to be set.
21+
*/
22+
public function phpIni(): array
23+
{
24+
return [
25+
];
5726
}
5827
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Native\Laravel\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use Native\Laravel\Contracts\ProvidesPhpIni;
7+
8+
class LoadPHPConfigurationCommand extends Command
9+
{
10+
protected $signature = 'native:php-ini';
11+
12+
public function handle()
13+
{
14+
/** @var ProvidesPhpIni $provider */
15+
$provider = app(config('nativephp.provider'));
16+
$phpIni = [];
17+
if (method_exists($provider, 'phpIni')) {
18+
$phpIni = $provider->phpIni();
19+
}
20+
echo json_encode($phpIni);
21+
}
22+
}

src/Contracts/ProvidesPhpIni.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Native\Laravel\Contracts;
4+
5+
interface ProvidesPhpIni
6+
{
7+
public function phpIni(): array;
8+
}

src/NativeServiceProvider.php

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Native\Laravel;
44

55
use Illuminate\Support\Arr;
6+
use Native\Laravel\Commands\LoadPHPConfigurationCommand;
67
use Native\Laravel\Commands\LoadStartupConfigurationCommand;
78
use Native\Laravel\Commands\MigrateCommand;
89
use Native\Laravel\Commands\MinifyApplicationCommand;
@@ -20,6 +21,7 @@ public function configurePackage(Package $package): void
2021
MigrateCommand::class,
2122
MinifyApplicationCommand::class,
2223
LoadStartupConfigurationCommand::class,
24+
LoadPHPConfigurationCommand::class,
2325
])
2426
->hasConfigFile()
2527
->hasRoute('api')

0 commit comments

Comments
 (0)