Skip to content

Commit 9989cab

Browse files
committed
Update Project Structure
1 parent d051c1f commit 9989cab

File tree

18 files changed

+190
-106
lines changed

18 files changed

+190
-106
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ storage/ci_sessions/*
156156
storage/cookie/*
157157
storage/paygate/*
158158
storage/logs/*
159+
storage/requests/*
159160
storage/tmp/*
160161
public/storage/tmp/*
161162
!/public/storage/tmp/.gitkeep
@@ -179,6 +180,9 @@ public/storage/tmp/*
179180
!/storage/logs/.gitkeep
180181
!/storage/logs/.htaccess
181182
!/storage/logs/index.html
183+
!/storage/requests/.gitkeep
184+
!/storage/requests/.htaccess
185+
!/storage/requests/index.html
182186
!/storage/tmp/.gitkeep
183187
!/storage/tmp/.htaccess
184188
!/storage/tmp/index.html

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
Change Log được viết theo biểu mẫu tại đây: https://keepachangelog.com/en/1.0.0/
44

5+
## [1.1.1] - 2024/02/02
6+
7+
### What's Changed
8+
9+
- [x] Add Start Application with Native PHP
10+
- [x] Update Docker PHP 8.0
11+
- [x] CHMOD Bash Script
12+
513
## [1.1.0] - 2024/01/23
614

715
### What's Changed

Dockerfile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:7.4-fpm
1+
FROM php:8.0-fpm
22

33
# Copy composer.lock and composer.json
44
# COPY composer.lock composer.json /var/www/
@@ -69,8 +69,15 @@ RUN apt-get update && apt-get install -y \
6969

7070
RUN pecl install imagick && docker-php-ext-enable imagick
7171

72+
# Install swoole ext
73+
#RUN pecl install swoole \
74+
# && docker-php-ext-enable swoole
75+
# Install mongodb ext
76+
#RUN pecl install mongodb \
77+
# && docker-php-ext-enable mongodb
78+
7279
# Install xdebug
73-
RUN pecl install xdebug && docker-php-ext-enable xdebug
80+
#RUN pecl install xdebug && docker-php-ext-enable xdebug
7481

7582
# remove not necessary files
7683
RUN rm -rf /var/lib/apt/lists/*
@@ -99,4 +106,10 @@ USER www
99106

100107
# Expose port 9000 and start php-fpm server
101108
EXPOSE 9000
102-
CMD ["php-fpm"]
109+
CMD ["php-fpm"]
110+
111+
# Add a script to monitor changes and update opcache files
112+
COPY ./docker/php/watcher.sh /watcher.sh
113+
RUN chmod +x /watcher.sh
114+
115+
CMD ["/watcher.sh"]

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ Replace `[my-app-name]` with the name of your new project directory, for example
2727
composer create-project nguyenanhung/codeigniter3-skeleton my-website
2828
```
2929

30+
## Start Application with Native PHP
31+
32+
Start PHP Server:
33+
34+
```shell
35+
composer start
36+
```
37+
38+
Open Service in URL
39+
40+
```shell
41+
http://localhost:8080/
42+
```
43+
3044
## Start Application on Docker
3145

3246
Quickly deploy the application with a pre-built Docker container:

app/libraries/Requests.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class Requests extends SimpleRequests
2727
public function __construct()
2828
{
2929
parent::__construct();
30-
$this->DEBUG = true;
31-
$this->logger_path = __DIR__ . '/../../storage/logs/Requests/';
30+
$this->DEBUG = false;
31+
$this->logger_path = __DIR__ . '/../../storage/requests/';
3232
$this->timeout = 60;
3333
$this->header = array();
3434
}

app/views/my_welcome.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@
236236
<h3>Hi there!</h3>
237237
<p>💡 I'm Hung and I'm a engineering manager in Hanoi, Vietnam.</p>
238238
<p>💻 Currently, I am working as a Engineering Manager at a software company in Hanoi, Vietnam.</p>
239-
<p>💻 My main work is in the fields of Ecommerce Tech, Edutech, Content Management System, DevOps and Project Management</p>
239+
<p>💻 My main work is in the fields of Ecommerce Tech, EdTech, Content Management System, DevOps and Project Management</p>
240240
<p>🌱 I live in a small town in Hanoi with my families, my wife and my son.</p>
241241
<p>💬 am passionated about PHP, Backend, Web, Security, Contribute Open Source and some of the things that</p>
242242
<p>Some of the things that I enjoy include: foods, travel, kungfu and photography. If you'd like to chat about them or anything else, feel free to get in touch with me on<a href="<?= $author->facebook ?>" target="_blank">facebook</a>,<a href="mailto:<?= $author->email ?>">email</a> or<a href="<?= $author->blog ?>" target="_blank">blog</a>.</p>

bash/script/clean-releases.sh

100644100755
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ echo "==================================================="
55

66
# Kiểm tra xem có tham số được truyền vào không
77
if [ -z "$1" ]; then
8-
echo "Cần chỉ định thư mục releases!"
9-
exit 1
8+
echo "Cần chỉ định thư mục releases!"
9+
exit 1
1010
fi
1111

1212
parent_folder="$1"
@@ -32,16 +32,16 @@ echo "==================================================="
3232

3333
# Giữ lại 3 thư mục có tên lớn nhất, xoá các thư mục khác
3434
for ((i = 0; i < ${#sorted_subfolders[@]}; i++)); do
35-
subfolder=${sorted_subfolders[i]}
36-
37-
# Điều chỉnh số bản releases được giữ lại tại đây
38-
if [ $i -lt 5 ]; then
39-
echo "Giữ lại thư mục: $subfolder"
40-
else
41-
echo "Xoá thư mục: $subfolder với lệnh (sudo rm -rf: $subfolder)"
42-
# Thêm lệnh để xoá thư mục khi bạn đã kiểm tra và chắc chắn rằng script hoạt động đúng
43-
sudo rm -rf "$subfolder"
44-
fi
35+
subfolder=${sorted_subfolders[i]}
36+
37+
# Điều chỉnh số bản releases được giữ lại tại đây
38+
if [ $i -lt 5 ]; then
39+
echo "Giữ lại thư mục: $subfolder"
40+
else
41+
echo "Xoá thư mục: $subfolder với lệnh (sudo rm -rf: $subfolder)"
42+
# Thêm lệnh để xoá thư mục khi bạn đã kiểm tra và chắc chắn rằng script hoạt động đúng
43+
sudo rm -rf "$subfolder"
44+
fi
4545
done
4646

4747
echo "==================================================="

bash/script/telegram.sh

100644100755
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ echo "==================================================="
55

66
# Kiểm tra xem có đủ 3 tham số không
77
if [ $# -ne 3 ]; then
8-
echo "Use: $0 <project_name> <message> <url>"
9-
exit 1
8+
echo "Use: $0 <project_name> <message> <url>"
9+
exit 1
1010
fi
1111

1212
# Lưu các tham số vào biến
@@ -19,8 +19,8 @@ telegram_bot_token="xxx"
1919

2020
# Gửi tin nhắn tới bot Telegram
2121
curl -s -X POST "https://api.telegram.org/bot$telegram_bot_token/sendMessage" \
22-
-d "chat_id=xxx" \
23-
-d "text=Project: $project_name%0AMessage: $message%0AURL: $url"
22+
-d "chat_id=xxx" \
23+
-d "text=Project: $project_name%0AMessage: $message%0AURL: $url"
2424

2525
echo ""
2626
#echo "Đã gửi thông báo thành công!"

bash/script/truncate-log.sh

100644100755
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,33 @@ echo "==================================================="
55

66
# Kiểm tra xem đã truyền đúng số lượng tham số hay chưa
77
if [ "$#" -ne 1 ]; then
8-
echo "Sử dụng: $0 <đường dẫn thư mục logs>"
9-
exit 1
8+
echo "Sử dụng: $0 <đường dẫn thư mục logs>"
9+
exit 1
1010
fi
1111

1212
# Lấy đường dẫn đến thư mục logs từ tham số
1313
logs_folder="$1"
1414

1515
# Kiểm tra xem thư mục logs tồn tại
1616
if [ ! -d "$logs_folder" ]; then
17-
echo "Thư mục logs không tồn tại."
18-
exit 1
17+
echo "Thư mục logs không tồn tại."
18+
exit 1
1919
fi
2020

2121
# Mảng tên các tệp log
2222
log_files=(
23-
"access.log"
24-
"error.log"
23+
"access.log"
24+
"error.log"
2525
)
2626

2727
# Duyệt qua từng tệp log và truncate chúng
2828
for log_file in "${log_files[@]}"; do
29-
if [ -f "$logs_folder/$log_file" ]; then
30-
truncate -s 0 "$logs_folder/$log_file"
31-
echo "Đã truncate tệp log $log_file."
32-
else
33-
echo "Tệp log $log_file không tồn tại trong thư mục logs."
34-
fi
29+
if [ -f "$logs_folder/$log_file" ]; then
30+
truncate -s 0 "$logs_folder/$log_file"
31+
echo "Đã truncate tệp log $log_file."
32+
else
33+
echo "Tệp log $log_file không tồn tại trong thư mục logs."
34+
fi
3535
done
3636

3737
echo "Đã truncate các tệp log trong thư mục logs."

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,9 @@
7676
"nguyenanhung/monitor": "Need support for Send Monitor Message to Monitor Service",
7777
"nguyenanhung/markdown": "Parser for Markdown",
7878
"nguyenanhung/basic-firewall": "PHP Basic Firewall - Library providing IP filtering features"
79+
},
80+
"prefer-stable": true,
81+
"scripts": {
82+
"start": "php -S localhost:8080 -t public"
7983
}
8084
}

0 commit comments

Comments
 (0)