Skip to content

Commit 88bd8c3

Browse files
authored
fix(laravel): installation command, fix config overwrites (#6649)
added the installation command, but as a bug fix since configs are currently getting overwritten. Closes: #6645
1 parent f2f06d1 commit 88bd8c3

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

src/Laravel/ApiPlatformProvider.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,10 @@ function (Application $app) {
10551055
if ($this->app['config']->get('api-platform.graphql.enabled')) {
10561056
$this->registerGraphQl($this->app);
10571057
}
1058+
1059+
if ($this->app->runningInConsole()) {
1060+
$this->commands([Console\InstallCommand::class]);
1061+
}
10581062
}
10591063

10601064
private function registerGraphQl(Application $app): void
@@ -1210,11 +1214,11 @@ public function boot(ResourceNameCollectionFactoryInterface $resourceNameCollect
12101214
if ($this->app->runningInConsole()) {
12111215
$this->publishes([
12121216
__DIR__.'/config/api-platform.php' => $this->app->configPath('api-platform.php'),
1213-
], 'laravel-assets');
1217+
], 'api-platform-config');
12141218

12151219
$this->publishes([
12161220
__DIR__.'/public' => $this->app->publicPath('vendor/api-platform'),
1217-
], 'laravel-assets');
1221+
], ['api-platform-assets', 'public']);
12181222
}
12191223

12201224
$this->loadViewsFrom(__DIR__.'/resources/views', 'api-platform');
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\Laravel\Console;
15+
16+
use Illuminate\Console\Command;
17+
use Symfony\Component\Console\Attribute\AsCommand;
18+
19+
#[AsCommand(name: 'api-platform:install')]
20+
class InstallCommand extends Command
21+
{
22+
/**
23+
* @var string
24+
*/
25+
protected $signature = 'api-platform:install';
26+
27+
/**
28+
* @var string
29+
*/
30+
protected $description = 'Install all of the API Platform resources';
31+
32+
/**
33+
* Execute the console command.
34+
*/
35+
public function handle(): void
36+
{
37+
$this->comment('Publishing API Platform Assets...');
38+
$this->callSilent('vendor:publish', ['--tag' => 'api-platform-assets']);
39+
40+
$this->comment('Publishing API Platform Configuration...');
41+
$this->callSilent('vendor:publish', ['--tag' => 'api-platform-config']);
42+
43+
$this->info('API Platform installed successfully.');
44+
}
45+
}

0 commit comments

Comments
 (0)