# Deployment Guide — Notch ERP

## Why you got "403 Forbidden / Access to this resource is denied"

Laravel's real entry point is the **`public/`** folder, not the project root.
When you upload the whole project to `public_html` and open the domain, the server
tries to list the project root (which is denied) → **403**.

This repository now ships a root **`.htaccess`** that automatically forwards every
request into `public/`, so uploading the whole folder works on most Apache/cPanel
shared hosts with **no extra configuration**.

---

## A) Shared hosting (cPanel / Apache) — no SSH needed

1. **Upload the whole project** into `public_html` (or a subfolder).
   Include the `vendor/` folder — shared hosts usually don't run Composer.
   - Zip the project locally → upload the zip → "Extract" in cPanel File Manager
     (make sure hidden files like `.htaccess` and `.env.example` are included).
2. **Set permissions** (cPanel File Manager → select folder → Permissions):
   - `storage/` and all subfolders → **755** (or 775)
   - `bootstrap/cache/` → **755** (or 775)
3. **PHP version**: set it to **8.2+** in cPanel ("Select PHP Version").
   Enable extensions: `pdo`, `pdo_mysql` (and/or `pdo_sqlite`), `mbstring`,
   `openssl`, `tokenizer`, `xml`, `ctype`, `json`, `bcmath`, `fileinfo`.
4. **Open your domain** in the browser. You'll be sent to the **Setup Wizard**.
   - `.env` and the app key are created automatically on first visit.
   - Step through: Requirements → **Database** (enter your MySQL DB name / user /
     password created in cPanel "MySQL Databases", host usually `localhost`) →
     **Administrator** account → **Modules** → Done.
5. Click **Go to Login** and sign in. 🎉

> Point the domain's document root directly at `public/` if your host lets you —
> it's slightly cleaner — but the included root `.htaccess` means you don't have to.

---

## B) VPS / local / any machine with CLI

```bash
bash setup.sh        # installs deps, .env, key, sqlite DB, modules, admin
php artisan serve
```
Open http://localhost:8000 — login `admin@notch.test` / `password`.

For production with Nginx/Apache, point the web root to `public/`.

---

## Reinstall / reset
Delete `storage/install.lock` (and your database) then revisit the site (web wizard)
or run `php artisan erp:install --fresh`.

---
---

# دليل التثبيت بالعربية 🇪🇬

## لماذا تظهر رسالة "403 Forbidden / Access denied"؟
لأن نقطة دخول لارافيل هي مجلد **`public/`** وليس جذر المشروع. عند رفع المشروع كامل
إلى `public_html` يحاول السيرفر فتح جذر المشروع فيمنع الوصول ← تظهر 403.
أضفنا ملف **`.htaccess`** في الجذر يقوم تلقائيًا بتحويل كل الطلبات إلى مجلد `public/`،
لذلك يكفي رفع المشروع كامل وسيعمل على معظم استضافات Apache/cPanel بدون أي إعداد إضافي.

## خطوات التثبيت على استضافة (cPanel):
1. **ارفع المشروع كامل** داخل `public_html` (مع مجلد `vendor`). الأسهل: اضغط المشروع
   ملف zip ثم ارفعه وفك الضغط من File Manager (تأكد من رفع الملفات المخفية مثل
   `.htaccess` و `.env.example`).
2. **الصلاحيات**: اجعل مجلد `storage` و `bootstrap/cache` على **755** أو **775**.
3. **إصدار PHP**: اختر **8.2 أو أحدث** من "Select PHP Version" وفعّل الإضافات:
   `pdo_mysql`, `mbstring`, `openssl`, `tokenizer`, `xml`, `ctype`, `json`, `bcmath`, `fileinfo`.
4. **افتح رابط موقعك** في المتصفح — سيتم تحويلك إلى **معالج التثبيت** تلقائيًا
   (يتم إنشاء ملف `.env` ومفتاح التطبيق تلقائيًا):
   - تحقق المتطلبات ← **قاعدة البيانات** (أنشئ قاعدة MySQL من cPanel وأدخل الاسم
     والمستخدم وكلمة المرور، والمضيف غالبًا `localhost`) ← **حساب المدير** ← **الوحدات** ← تم.
5. اضغط **تسجيل الدخول** وادخل ببياناتك. تم بنجاح ✅

## إعادة التثبيت:
احذف ملف `storage/install.lock` (وقاعدة البيانات) ثم افتح الموقع من جديد.
