@@ -42,7 +42,7 @@ function print_help() {
42
42
Very simple. First, change to the ext/ directory of the PHP sources. Then run
43
43
the following
44
44
45
- php ext_skel.php --ext extension_name
45
+ php ext_skel.php --ext extension_name --vendor vendor_name
46
46
47
47
and everything you need will be placed in directory ext/extension_name.
48
48
@@ -90,11 +90,12 @@ functions strictly needed by others. Exposed internal function must be named
90
90
91
91
OPTIONS
92
92
93
- php ext_skel.php --ext <name> [--experimental] [--author <name>]
94
- [--dir <path >] [--std ] [--onlyunix ]
95
- [--onlywindows] [--help]
93
+ php ext_skel.php --ext <name> --vendor <name> [--experimental ]
94
+ [--author <name >] [--dir <path> ] [--std ]
95
+ [--onlyunix] [-- onlywindows] [--help]
96
96
97
97
--ext <name> The name of the extension defined as <name>
98
+ --vendor <name> The vendor of the extension for Packagist
98
99
--experimental Passed if this extension is experimental, this creates
99
100
the EXPERIMENTAL file in the root of the extension
100
101
--author <name> Your name, this is used if --std is passed and for the
@@ -147,6 +148,7 @@ function process_args($argv, $argc) {
147
148
'unix ' => true ,
148
149
'windows ' => true ,
149
150
'ext ' => '' ,
151
+ 'vendor ' => '' ,
150
152
'dir ' => __DIR__ . DIRECTORY_SEPARATOR ,
151
153
'skel ' => __DIR__ . DIRECTORY_SEPARATOR . 'skeleton ' . DIRECTORY_SEPARATOR ,
152
154
'author ' => false ,
@@ -185,6 +187,7 @@ function process_args($argv, $argc) {
185
187
}
186
188
break ;
187
189
case 'ext ' :
190
+ case 'vendor ' :
188
191
case 'dir ' :
189
192
case 'author ' : {
190
193
if (!isset ($ argv [$ i + 1 ]) || ($ argv [$ i + 1 ][0 ] == '- ' && $ argv [$ i + 1 ][1 ] == '- ' )) {
@@ -204,6 +207,8 @@ function process_args($argv, $argc) {
204
207
205
208
if (empty ($ options ['ext ' ])) {
206
209
error ('No extension name passed, use "--ext <name>" ' );
210
+ } else if (empty ($ options ['vendor ' ])) {
211
+ error ('No vendor name passed, use "--vendor <name>" ' );
207
212
} else if (!$ options ['unix ' ] && !$ options ['windows ' ]) {
208
213
error ('Cannot pass both --onlyunix and --onlywindows ' );
209
214
} else if (!is_dir ($ options ['skel ' ])) {
@@ -217,6 +222,12 @@ function process_args($argv, $argc) {
217
222
.' Using only lower case letters is preferred. ' );
218
223
}
219
224
225
+ // Validate vendor
226
+ if (!preg_match ('/^[a-z][a-z0-9_-]+$/i ' , $ options ['vendor ' ])) {
227
+ error ('Invalid vendor name. Valid names start with a letter, '
228
+ .' followed by any number of letters, numbers, hypens, or underscores. ' );
229
+ }
230
+
220
231
$ options ['ext ' ] = str_replace (['\\' , '/ ' ], '' , strtolower ($ options ['ext ' ]));
221
232
222
233
return $ options ;
@@ -231,6 +242,7 @@ function process_source_tags($file, $short_name) {
231
242
error ('Unable to open file for reading: ' . $ short_name );
232
243
}
233
244
245
+ $ source = str_replace ('%VENDORNAME% ' , $ options ['vendor ' ], $ source );
234
246
$ source = str_replace ('%EXTNAME% ' , $ options ['ext ' ], $ source );
235
247
$ source = str_replace ('%EXTNAMECAPS% ' , strtoupper ($ options ['ext ' ]), $ source );
236
248
@@ -290,6 +302,7 @@ function copy_config_scripts() {
290
302
}
291
303
292
304
$ files [] = '.gitignore ' ;
305
+ $ files [] = 'composer.json ' ;
293
306
294
307
foreach ($ files as $ config_script ) {
295
308
$ new_config_script = $ options ['dir ' ] . $ options ['ext ' ] . DIRECTORY_SEPARATOR . $ config_script ;
0 commit comments