Skip to content

Commit 17dcd29

Browse files
authored
Make default php preset minimal (#3)
* Remove unnessary extensions from php preset * Fix laravel preset * Add copy button
1 parent da5d7fa commit 17dcd29

File tree

3 files changed

+113
-42
lines changed

3 files changed

+113
-42
lines changed

src/components/CopyCodeButton.astro

+19-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,24 @@ const { code } = Astro.props;
33
---
44

55
<button
6-
class="top-[0.9rem] right-2 absolute bg-gray-700 hover:bg-gray-600 px-2 copy-code py-1 rounded font-bold text-sm text-white"
6+
class="top-[0.9rem] right-2 absolute flex items-center gap-1 bg-gray-700 hover:bg-gray-600 px-2 copy-code py-1 rounded font-bold text-sm text-white"
77
data-code={code}
88
>
9+
<span>
10+
<svg
11+
xmlns="http://www.w3.org/2000/svg"
12+
width="16"
13+
height="16"
14+
viewBox="0 0 24 24"
15+
fill="none"
16+
stroke="currentColor"
17+
stroke-width="2"
18+
stroke-linecap="round"
19+
stroke-linejoin="round"
20+
><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path
21+
d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg
22+
>
23+
</span>
924
Copy
1025
</button>
1126

@@ -23,10 +38,11 @@ const { code } = Astro.props;
2338
button.addEventListener("click", () => {
2439
const code = button.getAttribute("data-code");
2540
copyToClipboard(code);
41+
const oldContent = button.getHTML();
2642
button.textContent = "Copied!";
2743
setTimeout(() => {
28-
button.textContent = "Copy";
29-
}, 2000);
44+
button.innerHTML = oldContent;
45+
}, 3000);
3046
});
3147
});
3248
</script>

src/presets/laravel.sh

+51-19
Original file line numberDiff line numberDiff line change
@@ -83,35 +83,67 @@ sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
8383
wait_for_apt_lock
8484
sudo apt-get update -y
8585

86-
# Install PHP with selected extensions
86+
# Install PHP with required extensions
87+
#
88+
# Core:
89+
# - fpm: FastCGI Process Manager
90+
# - cli: Command Line Interface
91+
#
92+
# Common:
93+
# - bcmath: Precise mathematical operations
94+
# - curl: HTTP requests support
95+
# - mbstring: Multibyte string handling
96+
# - intl: Internationalization support
97+
# - xml: XML parsing and generation
98+
# - zip: ZIP archive handling
99+
#
100+
# Database:
101+
# - mysql: MySQL/MariaDB database driver
102+
# - sqlite3: SQLite database driver
103+
# - pgsql: PostgreSQL database driver
104+
#
105+
# Image Processing:
106+
# - gd: Image creation and manipulation
107+
# - imagick: ImageMagick integration for advanced image processing
108+
#
109+
# Caching & Serialization:
110+
# - igbinary: Efficient data serialization
111+
# - memcached: Memcached caching system integration
112+
# - redis: Redis caching system integration
113+
#
114+
# Development & Testing:
115+
# - xdebug: Debugging and profiling tool
116+
# - pcov: Efficient PHP code coverage tool
87117
info "Installing PHP and extensions...\n"
88-
sudo apt-get install -y php$PHP_VERSION-fpm \
89-
php$PHP_VERSION-bcmath \
118+
sudo apt-get install -y zip unzip \
119+
php$PHP_VERSION-fpm \
90120
php$PHP_VERSION-cli \
91-
php$PHP_VERSION-common \
121+
php$PHP_VERSION-bcmath \
92122
php$PHP_VERSION-curl \
93-
php$PHP_VERSION-dev \
123+
php$PHP_VERSION-mbstring \
124+
php$PHP_VERSION-intl \
125+
php$PHP_VERSION-xml \
126+
php$PHP_VERSION-zip \
127+
php$PHP_VERSION-mysql \
128+
php$PHP_VERSION-sqlite3 \
129+
php$PHP_VERSION-pgsql \
94130
php$PHP_VERSION-gd \
95-
php$PHP_VERSION-igbinary \
96131
php$PHP_VERSION-imagick \
132+
php$PHP_VERSION-igbinary \
133+
php$PHP_VERSION-memcached \
134+
php$PHP_VERSION-redis \
135+
php$PHP_VERSION-xdebug \
136+
php$PHP_VERSION-pcov
137+
138+
# Install Laravel required extensions
139+
info "Installing extensions required by Laravel...\n"
140+
sudo apt-get install -y openssl \
97141
php$PHP_VERSION-imap \
98-
php$PHP_VERSION-intl \
99142
php$PHP_VERSION-ldap \
100-
php$PHP_VERSION-mbstring \
101-
php$PHP_VERSION-memcached \
102143
php$PHP_VERSION-msgpack \
103-
php$PHP_VERSION-mysql \
104-
php$PHP_VERSION-pcov \
105-
php$PHP_VERSION-pgsql \
106144
php$PHP_VERSION-readline \
107-
php$PHP_VERSION-redis \
108145
php$PHP_VERSION-soap \
109-
php$PHP_VERSION-sqlite3 \
110-
php$PHP_VERSION-swoole \
111-
php$PHP_VERSION-xdebug \
112-
php$PHP_VERSION-xml \
113-
php$PHP_VERSION-zip \
114-
zip unzip openssl
146+
php$PHP_VERSION-swoole
115147

116148
# Switch system's default PHP to the newly installed version
117149
sudo update-alternatives --set php /usr/bin/php$PHP_VERSION

src/presets/php.sh

+43-20
Original file line numberDiff line numberDiff line change
@@ -83,34 +83,57 @@ sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
8383
wait_for_apt_lock
8484
sudo apt-get update -y
8585

86-
# Install PHP with selected extensions
86+
# Install PHP with required extensions
87+
#
88+
# Core:
89+
# - fpm: FastCGI Process Manager
90+
# - cli: Command Line Interface
91+
#
92+
# Common:
93+
# - bcmath: Precise mathematical operations
94+
# - curl: HTTP requests support
95+
# - mbstring: Multibyte string handling
96+
# - intl: Internationalization support
97+
# - xml: XML parsing and generation
98+
# - zip: ZIP archive handling
99+
#
100+
# Database:
101+
# - mysql: MySQL/MariaDB database driver
102+
# - sqlite3: SQLite database driver
103+
# - pgsql: PostgreSQL database driver
104+
#
105+
# Image Processing:
106+
# - gd: Image creation and manipulation
107+
# - imagick: ImageMagick integration for advanced image processing
108+
#
109+
# Caching & Serialization:
110+
# - igbinary: Efficient data serialization
111+
# - memcached: Memcached caching system integration
112+
# - redis: Redis caching system integration
113+
#
114+
# Development & Testing:
115+
# - xdebug: Debugging and profiling tool
116+
# - pcov: Efficient PHP code coverage tool
87117
info "Installing PHP and extensions...\n"
88-
sudo apt-get install -y php$PHP_VERSION-fpm \
89-
php$PHP_VERSION-bcmath \
118+
sudo apt-get install -y zip unzip \
119+
php$PHP_VERSION-fpm \
90120
php$PHP_VERSION-cli \
121+
php$PHP_VERSION-bcmath \
91122
php$PHP_VERSION-curl \
92-
php$PHP_VERSION-dev \
123+
php$PHP_VERSION-mbstring \
124+
php$PHP_VERSION-intl \
125+
php$PHP_VERSION-xml \
126+
php$PHP_VERSION-zip \
127+
php$PHP_VERSION-mysql \
128+
php$PHP_VERSION-sqlite3 \
129+
php$PHP_VERSION-pgsql \
93130
php$PHP_VERSION-gd \
94-
php$PHP_VERSION-igbinary \
95131
php$PHP_VERSION-imagick \
96-
php$PHP_VERSION-imap \
97-
php$PHP_VERSION-intl \
98-
php$PHP_VERSION-ldap \
99-
php$PHP_VERSION-mbstring \
132+
php$PHP_VERSION-igbinary \
100133
php$PHP_VERSION-memcached \
101-
php$PHP_VERSION-msgpack \
102-
php$PHP_VERSION-mysql \
103-
php$PHP_VERSION-pcov \
104-
php$PHP_VERSION-pgsql \
105-
php$PHP_VERSION-readline \
106134
php$PHP_VERSION-redis \
107-
php$PHP_VERSION-soap \
108-
php$PHP_VERSION-sqlite3 \
109-
php$PHP_VERSION-swoole \
110135
php$PHP_VERSION-xdebug \
111-
php$PHP_VERSION-xml \
112-
php$PHP_VERSION-zip \
113-
zip unzip
136+
php$PHP_VERSION-pcov
114137

115138
# Switch system's default PHP to the newly installed version
116139
sudo update-alternatives --set php /usr/bin/php$PHP_VERSION

0 commit comments

Comments
 (0)