Skip to content

Commit 5539cf2

Browse files
Publish provider.stub in stub:publish command (#39491)
1 parent eb41172 commit 5539cf2

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/Illuminate/Foundation/Console/ProviderMakeCommand.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,20 @@ class ProviderMakeCommand extends GeneratorCommand
3434
*/
3535
protected function getStub()
3636
{
37-
return __DIR__.'/stubs/provider.stub';
37+
return $this->resolveStubPath('/stubs/provider.stub');
38+
}
39+
40+
/**
41+
* Resolve the fully-qualified path to the stub.
42+
*
43+
* @param string $stub
44+
* @return string
45+
*/
46+
protected function resolveStubPath($stub)
47+
{
48+
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
49+
? $customPath
50+
: __DIR__.$stub;
3851
}
3952

4053
/**

src/Illuminate/Foundation/Console/StubPublishCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function handle()
4545
__DIR__.'/stubs/notification.stub' => $stubsPath.'/notification.stub',
4646
__DIR__.'/stubs/observer.plain.stub' => $stubsPath.'/observer.plain.stub',
4747
__DIR__.'/stubs/observer.stub' => $stubsPath.'/observer.stub',
48+
__DIR__.'/stubs/provider.stub' => $stubsPath.'/provider.stub',
4849
__DIR__.'/stubs/request.stub' => $stubsPath.'/request.stub',
4950
__DIR__.'/stubs/resource-collection.stub' => $stubsPath.'/resource-collection.stub',
5051
__DIR__.'/stubs/resource.stub' => $stubsPath.'/resource.stub',

src/Illuminate/Foundation/Console/stubs/provider.stub

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

3-
namespace DummyNamespace;
3+
namespace {{ namespace }};
44

55
use Illuminate\Support\ServiceProvider;
66

7-
class DummyClass extends ServiceProvider
7+
class {{ class }} extends ServiceProvider
88
{
99
/**
1010
* Register services.

0 commit comments

Comments
 (0)