Conversie codeigniter 4
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
# PHP Docker Template
|
||||
|
||||
Template voor PHP projecten (CodeIgniter, plain PHP, etc.) met Xdebug support.
|
||||
|
||||
## Snelle start
|
||||
|
||||
### 1. Kopieer bestanden naar je project
|
||||
|
||||
```bash
|
||||
cp -r docker/ /pad/naar/jouw-project/
|
||||
cp docker-compose.yml /pad/naar/jouw-project/
|
||||
cp .env.example /pad/naar/jouw-project/.env
|
||||
```
|
||||
|
||||
### 2. Configureer je project
|
||||
|
||||
Pas `.env` aan:
|
||||
```env
|
||||
PROJECT_NAME=jouwproject
|
||||
PROJECT_DOMAIN=jouwproject.test
|
||||
DB_DATABASE=jouwproject_db
|
||||
```
|
||||
|
||||
### 3. Pas PHP versie aan (indien nodig)
|
||||
|
||||
In `docker-compose.yml`, wijzig de PHP_VERSION:
|
||||
```yaml
|
||||
args:
|
||||
PHP_VERSION: "8.2" # Opties: 7.4, 8.0, 8.1, 8.2, 8.3, 8.4
|
||||
```
|
||||
|
||||
### 4. Pas document root aan (indien nodig)
|
||||
|
||||
In `docker/nginx.conf`, wijzig root als je project geen `/public` map heeft:
|
||||
```nginx
|
||||
# Voor CodeIgniter 3:
|
||||
root /var/www/html;
|
||||
|
||||
# Voor CodeIgniter 4 / Laravel-style:
|
||||
root /var/www/html/public;
|
||||
```
|
||||
|
||||
### 5. DNS instellen
|
||||
|
||||
Voeg toe aan `/etc/hosts`:
|
||||
```
|
||||
127.0.0.1 jouwproject.test
|
||||
```
|
||||
|
||||
Of gebruik dnsmasq voor automatische .test domeinen.
|
||||
|
||||
### 6. Database aanmaken
|
||||
|
||||
```bash
|
||||
docker exec -it shared-mysql mysql -u root -proot -e "CREATE DATABASE jouwproject_db;"
|
||||
```
|
||||
|
||||
### 7. Start het project
|
||||
|
||||
```bash
|
||||
# Zorg dat shared services draaien
|
||||
cd /Volumes/development/sites/docker-shared
|
||||
docker compose up -d
|
||||
|
||||
# Start je project
|
||||
cd /pad/naar/jouw-project
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
Je project is nu beschikbaar op http://jouwproject.test
|
||||
|
||||
---
|
||||
|
||||
## Xdebug met PHPStorm
|
||||
|
||||
### 1. PHPStorm configureren
|
||||
|
||||
1. **Preferences → PHP → Servers**
|
||||
- Klik op `+`
|
||||
- Name: `jouwproject.test`
|
||||
- Host: `jouwproject.test`
|
||||
- Port: `80`
|
||||
- Debugger: `Xdebug`
|
||||
- ✅ Use path mappings
|
||||
- Map `/pad/naar/jouw-project` → `/var/www/html`
|
||||
|
||||
2. **Preferences → PHP → Debug**
|
||||
- Debug port: `9003`
|
||||
- ✅ Can accept external connections
|
||||
|
||||
3. **Preferences → PHP → Debug → DBGp Proxy**
|
||||
- IDE key: `PHPSTORM`
|
||||
|
||||
### 2. Debugging starten
|
||||
|
||||
1. Klik op de telefoon-icoon in PHPStorm: "Start Listening for PHP Debug Connections"
|
||||
2. Zet een breakpoint
|
||||
3. Open je pagina in de browser
|
||||
4. PHPStorm stopt automatisch bij je breakpoint
|
||||
|
||||
---
|
||||
|
||||
## Handige commando's
|
||||
|
||||
```bash
|
||||
# Start containers
|
||||
docker compose up -d
|
||||
|
||||
# Herbouw na Dockerfile wijzigingen
|
||||
docker compose up -d --build
|
||||
|
||||
# Stop containers
|
||||
docker compose down
|
||||
|
||||
# Bekijk logs
|
||||
docker compose logs -f
|
||||
|
||||
# Shell in PHP container
|
||||
docker exec -it jouwproject-app bash
|
||||
|
||||
# Composer commands
|
||||
docker exec -it jouwproject-app composer install
|
||||
docker exec -it jouwproject-app composer update
|
||||
|
||||
# Artisan commands (als je Laravel-achtige CLI hebt)
|
||||
docker exec -it jouwproject-app php artisan migrate
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Structuur
|
||||
|
||||
```
|
||||
jouw-project/
|
||||
├── docker/
|
||||
│ ├── Dockerfile # PHP container configuratie
|
||||
│ ├── nginx.conf # Nginx configuratie
|
||||
│ ├── php.ini # PHP settings
|
||||
│ └── xdebug.ini # Xdebug settings
|
||||
├── docker-compose.yml # Container orchestratie
|
||||
├── .env # Project variabelen
|
||||
└── ... je project bestanden
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Container kan shared-mysql niet bereiken
|
||||
Controleer of shared services draaien:
|
||||
```bash
|
||||
docker ps | grep shared-mysql
|
||||
```
|
||||
|
||||
### Xdebug werkt niet
|
||||
1. Check of xdebug actief is:
|
||||
```bash
|
||||
docker exec -it jouwproject-app php -m | grep xdebug
|
||||
```
|
||||
2. Check PHPStorm luistert op poort 9003
|
||||
3. Controleer path mapping in PHPStorm
|
||||
|
||||
### Permission denied errors
|
||||
```bash
|
||||
docker exec -it jouwproject-app chown -R www:www /var/www/html/storage
|
||||
```
|
||||
Reference in New Issue
Block a user