# Local and cPanel Setup

This project is now written to use environment-aware URLs and public paths, so the same source code can run locally and on cPanel without editing PHP files.

## Local

1. Copy `.env.example` to `.env`.
2. Set `APP_URL` to your local URL, for example `http://127.0.0.1:8000`.
3. Configure your database in `.env`.
4. Run:

```bash
php artisan key:generate
php artisan migrate
php artisan storage:link
php artisan serve
```

`php artisan serve` এখন standard Laravel `public/index.php` ব্যবহার করবে, তাই extra file move করার দরকার নেই।

## cPanel

1. Upload the same project code.
2. Best option:
   - Domain or subdomain document root `public` directory-তে point করুন।
3. Fallback option:
   - যদি cPanel-এ document root change করা না যায় এবং project root-ই expose হয়, তাহলেও root `index.php` + root `.htaccess` এখন request-কে `public/` front controller-এ পাঠাবে।
4. Create the server `.env` file from `.env.example`.
5. Set at minimum:
   - `APP_ENV=production`
   - `APP_DEBUG=false`
   - `APP_URL=https://your-domain.com`
   - `DB_*` values for your cPanel database
6. Make sure both web PHP and Terminal PHP are `8.2+`.
7. After upload, run this exact order from Terminal or SSH:

```bash
php -v
php artisan optimize:clear
php artisan migrate --force
php artisan storage:link
php artisan app:deploy-check
```

8. If `app:deploy-check` shows everything OK, then only cache again if needed:

```bash
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

9. If your app serves files from `storage/app/public`, also run:

```bash
php artisan storage:link
```

10. For scheduled jobs, add a cron entry that runs every minute:

```bash
php /home/USERNAME/path-to-project/artisan schedule:run >> /dev/null 2>&1
```

## Common reasons live hosting behaves differently

1. `APP_URL`, `APP_ENV`, or `APP_DEBUG` changed in `.env`, but old config cache is still active.
2. Web PHP and Terminal PHP are not the same version.
3. Live database is missing Gmail columns like `rate`, `admin_price`, `upline_commissions_snapshot`, or `stats_reset_at`.
4. `storage:link` was not created on the server.
5. Cron or queue worker is missing on hosting.
6. The live database contains older settings or older Gmail data than local.

Use `php artisan app:deploy-check` before debugging application code.

## Optional Branding

If you want a fixed public label or support email across environments, set:

```env
SITE_PUBLIC_LABEL=your-domain.com
SITE_SUPPORT_EMAIL=support@your-domain.com
```

If you leave them empty, the app will derive them automatically from the current request host.
