66
77class ApiCommand extends Command
88{
9+ protected $ signature = 'api:install ' ;
910
10- protected $ signature = 'api:install ' ;
11-
12- protected $ description = 'Install the API package ' ;
11+ protected $ description = 'Install the API package ' ;
1312
1413 protected string $ directory = '' ;
1514
@@ -41,10 +40,10 @@ protected function initDirectory()
4140 }
4241
4342 $ this ->makeDir ('/ ' );
44- $ this ->line ('<info>Api directory was created:</info> ' . str_replace (base_path (), '' , $ this ->directory ));
43+ $ this ->line ('<info>Api directory was created:</info> ' . str_replace (base_path (), '' , $ this ->directory ));
4544
4645 $ this ->makeDir ('Resources ' );
47- $ this ->line ('<info>Resources directory was created:</info> ' . str_replace (base_path (), '' , $ this ->directory ));
46+ $ this ->line ('<info>Resources directory was created:</info> ' . str_replace (base_path (), '' , $ this ->directory ));
4847
4948 $ this ->makeDir ('Controllers ' );
5049
@@ -58,88 +57,95 @@ protected function initDirectory()
5857 }
5958
6059 /**
61- * Notes : 创建基础控制器
60+ * Notes : 创建基础控制器.
61+ *
6262 * @Date : 2021/8/25 4:37 下午
6363 * @Author : <Jason.C>
6464 */
6565 protected function createBaseController ()
6666 {
67- $ baseController = $ this ->directory . '/Controllers/Controller.php ' ;
67+ $ baseController = $ this ->directory . '/Controllers/Controller.php ' ;
6868 $ contents = $ this ->getStub ('Controller ' );
6969
7070 $ this ->laravel ['files ' ]->put (
7171 $ baseController ,
7272 str_replace ('DummyNamespace ' , config ('api.route.namespace ' ), $ contents )
7373 );
74- $ this ->line ('<info>BaseController file was created:</info> ' . str_replace (base_path (), '' , $ baseController ));
74+ $ this ->line ('<info>BaseController file was created:</info> ' . str_replace (base_path (), '' , $ baseController ));
7575 }
7676
7777 /**
78- * Notes : 创建默认控制器
78+ * Notes : 创建默认控制器.
79+ *
7980 * @Date : 2021/8/25 4:37 下午
8081 * @Author : <Jason.C>
8182 */
8283 protected function createIndexController ()
8384 {
84- $ indexController = $ this ->directory . '/Controllers/IndexController.php ' ;
85+ $ indexController = $ this ->directory . '/Controllers/IndexController.php ' ;
8586 $ contents = $ this ->getStub ('IndexController ' );
8687
8788 $ this ->laravel ['files ' ]->put (
8889 $ indexController ,
8990 str_replace ('DummyNamespace ' , config ('api.route.namespace ' ), $ contents )
9091 );
91- $ this ->line ('<info>IndexController file was created:</info> ' . str_replace (base_path (), '' , $ indexController ));
92+ $ this ->line ('<info>IndexController file was created:</info> ' . str_replace (base_path (), '' , $ indexController ));
9293 }
9394
9495 /**
95- * Notes : 创建部署文件
96+ * Notes : 创建部署文件.
97+ *
9698 * @Date : 2021/8/25 4:37 下午
9799 * @Author : <Jason.C>
98100 */
99101 protected function createBootstrapFile ()
100102 {
101- $ file = $ this ->directory . '/bootstrap.php ' ;
103+ $ file = $ this ->directory . '/bootstrap.php ' ;
102104
103105 $ contents = $ this ->getStub ('bootstrap ' );
104106 $ this ->laravel ['files ' ]->put ($ file , $ contents );
105- $ this ->line ('<info>Bootstrap file was created:</info> ' . str_replace (base_path (), '' , $ file ));
107+ $ this ->line ('<info>Bootstrap file was created:</info> ' . str_replace (base_path (), '' , $ file ));
106108 }
107109
108110 /**
109- * Notes : 创建路由文件
111+ * Notes : 创建路由文件.
112+ *
110113 * @Date : 2021/8/25 4:37 下午
111114 * @Author : <Jason.C>
112115 */
113116 protected function createRoutesFile ()
114117 {
115- $ file = $ this ->directory . '/routes.php ' ;
118+ $ file = $ this ->directory . '/routes.php ' ;
116119
117120 $ contents = $ this ->getStub ('routes ' );
118121 $ this ->laravel ['files ' ]->put ($ file , $ contents );
119- $ this ->line ('<info>Routes file was created:</info> ' . str_replace (base_path (), '' , $ file ));
122+ $ this ->line ('<info>Routes file was created:</info> ' . str_replace (base_path (), '' , $ file ));
120123 }
121124
122125 /**
123- * Notes : 获取模板内容
126+ * Notes : 获取模板内容.
127+ *
124128 * @Date : 2021/8/25 4:37 下午
125129 * @Author : <Jason.C>
130+ *
126131 * @param $name
127132 * @return string
128133 */
129134 protected function getStub ($ name ): string
130135 {
131- return $ this ->laravel ['files ' ]->get (__DIR__ . "/stubs/ $ name.stub " );
136+ return $ this ->laravel ['files ' ]->get (__DIR__ . "/stubs/ $ name.stub " );
132137 }
133138
134139 /**
135- * Notes : 创建文件夹
140+ * Notes : 创建文件夹.
141+ *
136142 * @Date : 2021/8/25 4:37 下午
137143 * @Author : <Jason.C>
144+ *
138145 * @param string $path
139146 */
140147 protected function makeDir (string $ path = '' )
141148 {
142149 $ this ->laravel ['files ' ]->makeDirectory ("{$ this ->directory }/ $ path " , 0755 , true , true );
143150 }
144-
145151}
0 commit comments