File tree Expand file tree Collapse file tree 7 files changed +59
-24
lines changed Expand file tree Collapse file tree 7 files changed +59
-24
lines changed Original file line number Diff line number Diff line change 5
5
</p >
6
6
7
7
# A MVCS pattern create a service command for Laravel 5+
8
- Create a new service class and service contract
8
+ Create a new service class and service interface
9
9
10
10
# Install
11
11
``` bash
12
12
composer require getsolaris/laravel-make-service
13
13
```
14
14
15
+ # Suggest
16
+
17
+
18
+
15
19
# Usage
16
20
``` bash
17
- $ php artisan make:service {name : Create a service class} {--c : Optional of create a service contract }
21
+ $ php artisan make:service {name : Create a service class} {--i : Optional of create a service interface }
18
22
```
19
23
20
24
# Example
@@ -40,22 +44,28 @@ class UserService
40
44
}
41
45
```
42
46
43
- ## + Optional service contract
47
+ ## + Optional service interface
48
+
49
+ ```
50
+ v1.0.x -> contract
51
+ v1.1.x -> interface
52
+ ```
53
+
44
54
``` bash
45
- $ php artisan make:service UserService --c
55
+ $ php artisan make:service UserService --i
46
56
```
47
57
48
58
``` php
49
59
<?php
50
- // app/Http/Services/Contracts/UserServiceContract .php
60
+ // app/Http/Services/Contracts/UserServiceInterface .php
51
61
52
- namespace App\Services\Contracts ;
62
+ namespace App\Services\Interfaces ;
53
63
54
64
/**
55
- * Interface UserServiceContract
56
- * @package App\Services\Contracts
65
+ * Interface UserServiceInterface
66
+ * @package App\Services\Interfaces
57
67
*/
58
- interface UserServiceContract
68
+ interface UserServiceInterface
59
69
{
60
70
61
71
}
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace {{ namespace }};
4
+
5
+ use {{ namespace }}\Contracts\{{ class }}Contract;
6
+
7
+ /**
8
+ * Class {{ class }}
9
+ * @package App\Services
10
+ */
11
+ class {{ class }} implements {{ class }}Contract
12
+ {
13
+
14
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 2
2
3
3
namespace {{ namespace }};
4
4
5
- use {{ namespace }}\Contracts\{{ class }}Contract;
6
-
7
5
/**
8
6
* Class {{ class }}
9
7
* @package App\Services
10
8
*/
11
- class {{ class }} implements {{ class }}Contract
9
+ class {{ class }}
12
10
{
13
11
14
12
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use PHPUnit \Framework \TestCase ;
4
+
5
+ class MakeFileExistTest extends TestCase
6
+ {
7
+ public function test_console_command (): void
8
+ {
9
+ $ this ->artisan ('make:service ' );
10
+ }
11
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use PHPUnit \Framework \TestCase ;
4
+
5
+ class MakeTest extends TestCase
6
+ {
7
+ public function test_exist_service_stub (): void
8
+ {
9
+ $ this ->assertFileExists (
10
+ 'service.stub ' ,
11
+ "given filename doesn't exists "
12
+ );
13
+ }
14
+ }
You can’t perform that action at this time.
0 commit comments