Skip to content

Commit 93857cd

Browse files
authored
Merge pull request #122 from bowphp/feat/add-docs
Update install and scheduler
2 parents 93087f2 + 6359003 commit 93857cd

4 files changed

Lines changed: 728 additions & 290 deletions

File tree

docs/installation.mdx

Lines changed: 235 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Si vous découvrez Composer, prenez le temps de parcourir sa [documentation](htt
4040

4141
[![asciicast](https://asciinema.org/a/s8HpeoaUwnxEZ7OOPRxxXE52z.svg)](https://asciinema.org/a/s8HpeoaUwnxEZ7OOPRxxXE52z)
4242

43-
## 🚀 Démarrer votre projet
43+
## Démarrer votre projet
4444

4545
Rendez-vous à la racine de votre projet et démarrez le serveur de développement :
4646

@@ -60,7 +60,7 @@ php bow run:server
6060
```
6161
:::
6262

63-
## ⚙️ Configuration
63+
## Configuration
6464

6565
### Dossier public
6666

@@ -119,33 +119,237 @@ RewriteRule ^ index.php [L]
119119
120120
### Nginx
121121
122-
Pour Nginx, ajoutez cette configuration dans votre bloc `server` :
122+
Pour Nginx, ajoutez cette configuration dans votre fichier de site :
123123
124-
```nginx
124+
```nginx title="/etc/nginx/sites-available/bow-app"
125125
server {
126-
listen 80;
127-
server_name example.com;
128-
root /path/to/your/project/public;
129-
130-
index index.php index.html;
131-
132-
location / {
133-
try_files $uri $uri/ /index.php?$query_string;
134-
}
135-
136-
location ~ \.php$ {
137-
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
138-
fastcgi_index index.php;
139-
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
140-
include fastcgi_params;
141-
}
142-
143-
location ~ /\.(?!well-known).* {
144-
deny all;
145-
}
126+
listen 80;
127+
server_name example.com www.example.com;
128+
root /var/www/bow-app/public;
129+
index index.php;
130+
131+
# Logs
132+
access_log /var/log/nginx/bow-app.access.log;
133+
error_log /var/log/nginx/bow-app.error.log;
134+
135+
# Sécurité - Headers
136+
add_header X-Frame-Options "SAMEORIGIN" always;
137+
add_header X-Content-Type-Options "nosniff" always;
138+
add_header X-XSS-Protection "1; mode=block" always;
139+
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
140+
141+
# Gzip compression
142+
gzip on;
143+
gzip_vary on;
144+
gzip_min_length 1024;
145+
gzip_types text/plain text/css text/xml text/javascript
146+
application/javascript application/json application/xml;
147+
148+
# Front Controller
149+
location / {
150+
try_files $uri $uri/ /index.php?$query_string;
151+
}
152+
153+
# PHP-FPM
154+
location ~ \.php$ {
155+
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
156+
fastcgi_index index.php;
157+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
158+
include fastcgi_params;
159+
fastcgi_hide_header X-Powered-By;
160+
}
161+
162+
# Cache des assets statiques
163+
location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|eot)$ {
164+
expires 1y;
165+
add_header Cache-Control "public, immutable";
166+
access_log off;
167+
}
168+
169+
# Bloquer l'accès aux fichiers sensibles
170+
location ~ /\.(env|git|htaccess) {
171+
deny all;
172+
}
173+
174+
location ~ ^/(var|vendor|config|migrations|seeders)/ {
175+
deny all;
176+
}
146177
}
147178
```
148179

180+
#### Nginx avec SSL (HTTPS)
181+
182+
```nginx title="/etc/nginx/sites-available/bow-app-ssl"
183+
server {
184+
listen 80;
185+
server_name example.com www.example.com;
186+
return 301 https://$server_name$request_uri;
187+
}
188+
189+
server {
190+
listen 443 ssl http2;
191+
server_name example.com www.example.com;
192+
root /var/www/bow-app/public;
193+
index index.php;
194+
195+
# Certificats SSL (Let's Encrypt)
196+
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
197+
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
198+
199+
# Configuration SSL moderne
200+
ssl_protocols TLSv1.2 TLSv1.3;
201+
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
202+
ssl_prefer_server_ciphers off;
203+
ssl_session_timeout 1d;
204+
ssl_session_cache shared:SSL:50m;
205+
ssl_stapling on;
206+
ssl_stapling_verify on;
207+
208+
# Headers de sécurité
209+
add_header Strict-Transport-Security "max-age=63072000" always;
210+
add_header X-Frame-Options "SAMEORIGIN" always;
211+
add_header X-Content-Type-Options "nosniff" always;
212+
213+
location / {
214+
try_files $uri $uri/ /index.php?$query_string;
215+
}
216+
217+
location ~ \.php$ {
218+
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
219+
fastcgi_index index.php;
220+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
221+
include fastcgi_params;
222+
}
223+
224+
location ~ /\.(env|git|htaccess) {
225+
deny all;
226+
}
227+
}
228+
```
229+
230+
#### Activer le site Nginx
231+
232+
```bash
233+
# Créer le lien symbolique
234+
sudo ln -s /etc/nginx/sites-available/bow-app /etc/nginx/sites-enabled/
235+
236+
# Tester la configuration
237+
sudo nginx -t
238+
239+
# Recharger Nginx
240+
sudo systemctl reload nginx
241+
```
242+
243+
### Docker
244+
245+
Pour développer avec Docker, créez les fichiers suivants à la racine du projet :
246+
247+
```dockerfile title="Dockerfile"
248+
FROM php:8.2-fpm-alpine
249+
250+
# Extensions PHP
251+
RUN apk add --no-cache \
252+
libpng-dev libjpeg-turbo-dev freetype-dev \
253+
oniguruma-dev libxml2-dev zip unzip git curl \
254+
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
255+
&& docker-php-ext-install pdo pdo_mysql mbstring xml gd opcache
256+
257+
# Composer
258+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
259+
260+
WORKDIR /var/www/html
261+
262+
COPY . .
263+
264+
RUN composer install --no-dev --optimize-autoloader \
265+
&& chown -R www-data:www-data var/
266+
267+
EXPOSE 9000
268+
269+
CMD ["php-fpm"]
270+
```
271+
272+
```yaml title="docker-compose.yml"
273+
services:
274+
app:
275+
build: .
276+
volumes:
277+
- .:/var/www/html
278+
- ./var:/var/www/html/var
279+
depends_on:
280+
- mysql
281+
- redis
282+
networks:
283+
- bow-network
284+
285+
nginx:
286+
image: nginx:alpine
287+
ports:
288+
- "8080:80"
289+
volumes:
290+
- .:/var/www/html
291+
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf
292+
depends_on:
293+
- app
294+
networks:
295+
- bow-network
296+
297+
mysql:
298+
image: mysql:8.0
299+
environment:
300+
MYSQL_ROOT_PASSWORD: secret
301+
MYSQL_DATABASE: bow_app
302+
MYSQL_USER: bow
303+
MYSQL_PASSWORD: secret
304+
volumes:
305+
- mysql-data:/var/lib/mysql
306+
ports:
307+
- "3306:3306"
308+
networks:
309+
- bow-network
310+
311+
redis:
312+
image: redis:alpine
313+
ports:
314+
- "6379:6379"
315+
networks:
316+
- bow-network
317+
318+
networks:
319+
bow-network:
320+
driver: bridge
321+
322+
volumes:
323+
mysql-data:
324+
```
325+
326+
```nginx title="docker/nginx.conf"
327+
server {
328+
listen 80;
329+
root /var/www/html/public;
330+
index index.php;
331+
332+
location / {
333+
try_files $uri $uri/ /index.php?$query_string;
334+
}
335+
336+
location ~ \.php$ {
337+
fastcgi_pass app:9000;
338+
fastcgi_index index.php;
339+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
340+
include fastcgi_params;
341+
}
342+
}
343+
```
344+
345+
```bash
346+
# Démarrer les conteneurs
347+
docker-compose up -d
348+
349+
# Accéder à l'application
350+
# http://localhost:8080
351+
```
352+
149353
### Déploiement sur serveur mutualisé
150354

151355
Pour déployer Bow Framework sur un hébergement mutualisé :
@@ -177,18 +381,18 @@ Options -indexes
177381
```
178382
179383
:::tip Gestion des assets
180-
Pour un hébergement mutualisé, utilisez le helper `app_assets()` pour vos fichiers statiques et modifiez la valeur de `APP_ASSET_PREFIX` à `/public` dans votre fichier `.env.json`. Bow gérera automatiquement les chemins corrects ! 🚀
384+
Pour un hébergement mutualisé, utilisez le helper `app_assets()` pour vos fichiers statiques et modifiez la valeur de `APP_ASSET_PREFIX` à `/public` dans votre fichier `.env.json`. Bow gérera automatiquement les chemins corrects !
181385
:::
182386
183387
## Prochaines étapes
184388
185389
Maintenant que votre installation est terminée, découvrez comment construire votre application :
186390
187-
- 🛣️ [Créer vos premières routes](./routing)
188-
- 🎮 [Utiliser les contrôleurs](./controller)
189-
- 💾 [Travailler avec les bases de données](./database)
190-
- 🔐 [Gérer les sessions utilisateur](./session)
191-
- 📦 [Utiliser le système de stockage](./storage)
192-
- 🎨 [Créer des vues avec Tintin](./views)
391+
- [Créer vos premières routes](./routing)
392+
- [Utiliser les contrôleurs](./controller)
393+
- [Travailler avec les bases de données](./database)
394+
- [Gérer les sessions utilisateur](./session)
395+
- [Utiliser le système de stockage](./storage)
396+
- [Créer des vues avec Tintin](./views)
193397
194398
<SuggestionFeature />

0 commit comments

Comments
 (0)