Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d9ca72f

Browse files
authored
Add composer.json.in to ext/skeleton for PIE support (#19853)
* Add composer.json.in to ext/skeleton for PIE support * Add --vendor param to ext_skel.php to provide vendor name for PIE packages
1 parent dcc4b0f commit d9ca72f

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

‎ext/ext_skel.php‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function print_help() {
4242
Very simple. First, change to the ext/ directory of the PHP sources. Then run
4343
the following
4444
45-
php ext_skel.php --ext extension_name
45+
php ext_skel.php --ext extension_name --vendor vendor_name
4646
4747
and everything you need will be placed in directory ext/extension_name.
4848
@@ -90,11 +90,12 @@ functions strictly needed by others. Exposed internal function must be named
9090
9191
OPTIONS
9292
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]
9696
9797
--ext <name> The name of the extension defined as <name>
98+
--vendor <name> The vendor of the extension for Packagist
9899
--experimental Passed if this extension is experimental, this creates
99100
the EXPERIMENTAL file in the root of the extension
100101
--author <name> Your name, this is used if --std is passed and for the
@@ -147,6 +148,7 @@ function process_args($argv, $argc) {
147148
'unix' => true,
148149
'windows' => true,
149150
'ext' => '',
151+
'vendor' => '',
150152
'dir' => __DIR__ . DIRECTORY_SEPARATOR,
151153
'skel' => __DIR__ . DIRECTORY_SEPARATOR . 'skeleton' . DIRECTORY_SEPARATOR,
152154
'author' => false,
@@ -185,6 +187,7 @@ function process_args($argv, $argc) {
185187
}
186188
break;
187189
case 'ext':
190+
case 'vendor':
188191
case 'dir':
189192
case 'author': {
190193
if (!isset($argv[$i + 1]) || ($argv[$i + 1][0] == '-' && $argv[$i + 1][1] == '-')) {
@@ -204,6 +207,8 @@ function process_args($argv, $argc) {
204207

205208
if (empty($options['ext'])) {
206209
error('No extension name passed, use "--ext <name>"');
210+
} else if (empty($options['vendor'])) {
211+
error('No vendor name passed, use "--vendor <name>"');
207212
} else if (!$options['unix'] && !$options['windows']) {
208213
error('Cannot pass both --onlyunix and --onlywindows');
209214
} else if (!is_dir($options['skel'])) {
@@ -217,6 +222,12 @@ function process_args($argv, $argc) {
217222
.' Using only lower case letters is preferred.');
218223
}
219224

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+
220231
$options['ext'] = str_replace(['\\', '/'], '', strtolower($options['ext']));
221232

222233
return $options;
@@ -231,6 +242,7 @@ function process_source_tags($file, $short_name) {
231242
error('Unable to open file for reading: ' . $short_name);
232243
}
233244

245+
$source = str_replace('%VENDORNAME%', $options['vendor'], $source);
234246
$source = str_replace('%EXTNAME%', $options['ext'], $source);
235247
$source = str_replace('%EXTNAMECAPS%', strtoupper($options['ext']), $source);
236248

@@ -290,6 +302,7 @@ function copy_config_scripts() {
290302
}
291303

292304
$files[] = '.gitignore';
305+
$files[] = 'composer.json';
293306

294307
foreach($files as $config_script) {
295308
$new_config_script = $options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . $config_script;

‎ext/skeleton/composer.json.in‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "%VENDORNAME%/%EXTNAME%",
3+
"type": "php-ext",
4+
"license": "BSD-3-Clause",
5+
"description": "Describe your extension here",
6+
"require": {
7+
"php": "^8.3"
8+
},
9+
"php-ext": {
10+
"extension-name": "%EXTNAME%",
11+
"configure-options": [
12+
{
13+
"name": "enable-%EXTNAME%",
14+
"needs-value": false,
15+
"description": "whether to enable %EXTNAME% support"
16+
}
17+
]
18+
}
19+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /