Skip to content
This repository was archived by the owner on Nov 27, 2022. It is now read-only.

Commit c8f4740

Browse files
committed
Defined own stub
Using a self defined stub allows more granular control like the declaration of the 404 page which can be passed as an argument into the method Phar::webPhar.
1 parent d3d8e66 commit c8f4740

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

box.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
22
"alias": "pocs.phar",
33
"output": "build/pocs.phar",
4-
"main": "web/index.php",
54
"compression": "NONE",
6-
"directories": ["src", "Resources", "vendor", "web"],
5+
"directories": ["src", "share", "vendor", "web"],
76
"files": [
87
"LICENSE"
98
],
9+
"blacklist": [
10+
"share/phar/stub.php"
11+
],
1012
"replacements": {
1113
"version": "0.0.1"
1214
},
1315
"shebang": false,
14-
"stub": true,
16+
"stub": "share/phar/stub.php",
1517
"web": true
1618
}

share/phar/404.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php http_response_code(404); ?>
2+
File not found!

share/phar/stub.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
$mimes = array(
4+
'c' => 'text/plain',
5+
'cc' => 'text/plain',
6+
'cpp' => 'text/plain',
7+
'c++' => 'text/plain',
8+
'dtd' => 'text/plain',
9+
'h' => 'text/plain',
10+
'log' => 'text/plain',
11+
'rng' => 'text/plain',
12+
'txt' => 'text/plain',
13+
'xsd' => 'text/plain',
14+
'php' => Phar::PHP, // parse as PHP
15+
'inc' => Phar::PHP, // parse as PHP
16+
'avi' => 'video/avi',
17+
'bmp' => 'image/bmp',
18+
'css' => 'text/css',
19+
'gif' => 'image/gif',
20+
'htm' => 'text/html',
21+
'html' => 'text/html',
22+
'htmls' => 'text/html',
23+
'ico' => 'image/x-ico',
24+
'jpe' => 'image/jpeg',
25+
'jpg' => 'image/jpeg',
26+
'jpeg' => 'image/jpeg',
27+
'js' => 'application/x-javascript',
28+
'midi' => 'audio/midi',
29+
'mid' => 'audio/midi',
30+
'mod' => 'audio/mod',
31+
'mov' => 'movie/quicktime',
32+
'mp3' => 'audio/mp3',
33+
'mpg' => 'video/mpeg',
34+
'mpeg' => 'video/mpeg',
35+
'pdf' => 'application/pdf',
36+
'png' => 'image/png',
37+
'swf' => 'application/shockwave-flash',
38+
'tif' => 'image/tiff',
39+
'tiff' => 'image/tiff',
40+
'wav' => 'audio/wav',
41+
'xbm' => 'image/xbm',
42+
'xml' => 'text/xml',
43+
);
44+
45+
Phar::webPhar(
46+
'pocs.phar',
47+
'web/index.php',
48+
'share/phar/404.php',
49+
$mimes
50+
);
51+
52+
__HALT_COMPILER();

0 commit comments

Comments
 (0)