# Commandes de déploiement — influencer-api

---

## Premier déploiement

**1. Dépendances**
```bash
composer install --no-dev --optimize-autoloader
```

**2. Environnement**
```bash
cp .env.example .env
php artisan key:generate
```

**3. Migrations**
```bash
php artisan migrate --force
```

**4. Passport (OAuth2)**
```bash
php artisan passport:keys --force
php artisan passport:client --personal --name="Personal Access Client" --no-interaction
```

**5. Données initiales**
```bash
php artisan db:seed --force
```

**6. Token service-to-service**
```bash
php artisan service:token:generate
```
Ajouter la clé générée dans `.env` de core-api  avec l'url de l'api:

``
INFLUENCER_API_URL=http://influencer.localhost/api/v1/service
INFLUENCER_SERVICE_TOKEN=odLCJpDCmzzJet1xF2TNYFk1N5eLznTlRl4RuLFaMwfHNYYzTDdzeH8wCsJuGj42
``

Enregistrer l'application sur byPlus et copier les clés public et secrete dns le .env avec l'url de l'api
```
BY_PLUS_API_URL=https://core.domaine.com/api/v1
BY_PLUS_PUBLIC_KEY=pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
BY_PLUS_SECRET_KEY=sk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

**7. Permissions**
```bash
chown -R www-data:www-data storage bootstrap/cache
chmod -R 775 storage bootstrap/cache
chmod 600 storage/oauth-public.key storage/oauth-private.key

```

**8. Cache**
```bash
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

**9. Horizon (files d'attente)**
```bash
supervisorctl start influencer-horizon
```

---

## Mise à jour

**1. Code**
```bash
git pull origin main
composer install --no-dev --optimize-autoloader
```

**2. Arrêter Horizon**
```bash
php artisan horizon:terminate
```

**3. Migrations**
```bash
php artisan migrate --force
```

**4. Cache**
```bash
php artisan optimize:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache
```
