Skip to content

Commit 4a89acd

Browse files
committed
change command
1 parent 01bb45e commit 4a89acd

File tree

2 files changed

+72
-4
lines changed

2 files changed

+72
-4
lines changed

src/Command/VercelInstallCommand.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8080
$io->success('Generate vercel.json file successfully for PHP '.$phpversion);
8181

8282

83-
try {
84-
$filesystem->symlink($this->rootDirectory.'/public',$this->rootDirectory . '/api', true);
85-
} catch (IOExceptionInterface $exception) {
86-
echo "An error occurred while creating your directory at ".$exception->getPath();
83+
if($filesystem->exists($this->rootDirectory. '/api')){
84+
$io->error('A /api already exist, Vercel require a /api directory, please remove it');
85+
}else{
86+
try {
87+
$filesystem->mkdir($this->rootDirectory . '/api');
88+
$filesystem->copy($this->rootDirectory.'/public/index.php',$this->rootDirectory . '/api/index.php', true);
89+
$filesystem->copy(__DIR__ . '/../../tocopy/assets.php',$this->rootDirectory . '/api/assets.php', true);
90+
} catch (IOExceptionInterface $exception) {
91+
echo "An error occurred while creating your directory at ".$exception->getPath();
92+
}
8793
}
8894

8995

tocopy/assets.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
$file = __DIR__ . '/../public/' . $_SERVER['SCRIPT_NAME'];
3+
4+
$path_parts = pathinfo($file);
5+
$extension = $path_parts['extension'];
6+
7+
switch(strtolower($extension)) {
8+
case 'css':
9+
header('content-type: text/css');
10+
break;
11+
case 'js':
12+
header('content-type: application/javascript');
13+
break;
14+
case 'png':
15+
header('content-type: image/png');
16+
break;
17+
case 'jpg':
18+
header('content-type: image/jpeg');
19+
break;
20+
case 'gif':
21+
header('content-type: image/gif');
22+
break;
23+
case 'ico':
24+
header('content-type: image/x-icon');
25+
break;
26+
case 'svg':
27+
header('content-type: image/svg+xml');
28+
break;
29+
case 'woff':
30+
header('content-type: application/font-woff');
31+
break;
32+
case 'woff2':
33+
header('content-type: application/font-woff2');
34+
break;
35+
case 'ttf':
36+
header('content-type: application/font-sfnt');
37+
break;
38+
case 'eot':
39+
header('content-type: application/vnd.ms-fontobject');
40+
break;
41+
case 'otf':
42+
header('content-type: font/opentype');
43+
break;
44+
case 'json':
45+
header('content-type: application/json');
46+
break;
47+
case 'xml':
48+
header('content-type: application/xml');
49+
break;
50+
case 'txt':
51+
header('content-type: text/plain');
52+
break;
53+
case 'pdf':
54+
header('content-type: application/pdf');
55+
break;
56+
default:
57+
die();
58+
}
59+
60+
$im = file_get_contents($file);
61+
echo $im;
62+

0 commit comments

Comments
 (0)