# Deploy WapAPI on cPanel

## Requirements

- **PHP 8.2 or 8.3** (Laravel 11 — works on PHP 8.2.32)
- MySQL / MariaDB
- Composer
- Extensions: `openssl`, `mbstring`, `pdo_mysql`, `tokenizer`, `json`, `curl`, `fileinfo`, `ctype`

> Important: Select PHP 8.2+ in cPanel → **Select PHP Version** (or MultiPHP) for both the domain and SSH/CLI.

## Steps

1. Upload the **updated** project files (or pull latest) to e.g. `~/api.datatech.click`
2. Document root must point to the `public` folder
3. Copy `.env.example` to `.env` and configure DB + `APP_URL`

```env
APP_NAME=WapAPI
APP_URL=https://api.datatech.click
APP_LOCALE=ar
APP_DEBUG=false

DB_CONNECTION=mysql
DB_HOST=localhost
DB_DATABASE=your_db
DB_USERNAME=your_user
DB_PASSWORD=your_password

QUEUE_CONNECTION=database
CACHE_STORE=database
SESSION_DRIVER=database
```

4. On the server (SSH), from the project root:

```bash
# If you previously installed Laravel 13 packages, clean first:
rm -rf vendor composer.lock

# Then install (PHP 8.2 compatible)
composer install --no-dev --optimize-autoloader

php artisan key:generate
php artisan migrate --seed --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

5. Permissions:

```bash
chmod -R 775 storage bootstrap/cache
```

6. Cron (cPanel → Cron Jobs):

```bash
* * * * * cd /home/USER/api.datatech.click && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1
```

Use the same PHP binary path that cPanel shows for PHP 8.2 (sometimes `/usr/local/bin/ea-php82` or similar).

## Fix: "require PHP >= 8.3.0"

That error means the old `vendor/` was built for **Laravel 13**. After uploading the fixed project:

```bash
rm -rf vendor
composer install --no-dev --optimize-autoloader
php artisan key:generate
```

Confirm:

```bash
php -v
php artisan --version
# should show Laravel Framework 11.x
```

## Evolution note

Evolution API runs on a VPS/Docker host. Configure Base URL + API key in Admin → Settings.

## Security checklist

- Change seeded passwords and delete the demo API key
- Set `APP_DEBUG=false`
- Use HTTPS
- Rotate Meta / Evolution credentials regularly
