151 lines
5.0 KiB
Markdown
151 lines
5.0 KiB
Markdown
---
|
|
judul: SFA CMS — Setup Development Lokal
|
|
proyek: SFA CMS
|
|
terkait: Mito
|
|
stack: Laravel · Filament · PHP 8.3 native (tanpa Docker) · MySQL
|
|
kategori: Deploy & Setup
|
|
status: Aktif
|
|
tipe: dokumen-internal
|
|
tags:
|
|
- sfa
|
|
- cms
|
|
- setup
|
|
- development
|
|
- laravel
|
|
---
|
|
|
|
> Index: [[SFA — Index]] · Kategori: **Deploy & Setup**
|
|
>
|
|
> Cara menjalankan SFA-CMS di laptop pakai PHP native (bukan Docker), plus penjelasan
|
|
> skema database yang direkonstruksi dari kode. Versi production-nya:
|
|
> [[SFA CMS — Deployment VPS MITO]]
|
|
|
|
# Menjalankan SFA-CMS (PHP native, tanpa Docker)
|
|
|
|
## Prasyarat (sudah terpasang lewat Homebrew)
|
|
|
|
| Tool | Versi | Catatan |
|
|
|---|---|---|
|
|
| PHP | 8.3.33 | `php@8.3` keg-only, PATH sudah ditambahkan ke `~/.zshrc` |
|
|
| Composer | 2.10.2 | |
|
|
| MySQL | 26.7.0 | jalan sebagai service: `brew services start mysql` |
|
|
|
|
Ekstensi PHP yang dipakai aplikasi sudah aktif bawaan formula:
|
|
`pdo_mysql mbstring bcmath gd zip intl exif pcntl curl openssl fileinfo tokenizer xml`
|
|
|
|
## Menjalankan
|
|
|
|
```bash
|
|
cd /Users/chelvynkleden/developer/SINERKA/snk_sfa-cms
|
|
php artisan serve --host=127.0.0.1 --port=8000
|
|
```
|
|
|
|
Akses **http://127.0.0.1:8000** → redirect ke `/login`.
|
|
|
|
```
|
|
email : admin@sfacms.test
|
|
password : password
|
|
```
|
|
|
|
Kalau MySQL belum jalan: `brew services start mysql`
|
|
(cek: `brew services list`).
|
|
|
|
## Database
|
|
|
|
```
|
|
DB_CONNECTION=mysql
|
|
DB_HOST=127.0.0.1 DB_PORT=3306
|
|
DB_DATABASE=sfacms DB_USERNAME=sfacms DB_PASSWORD=secret
|
|
```
|
|
|
|
User `sfacms` dibuat untuk host `localhost` dan `127.0.0.1`.
|
|
|
|
```bash
|
|
mysql -usfacms -psecret sfacms # masuk ke shell mysql
|
|
php artisan migrate # jalankan migration
|
|
php artisan migrate:status # cek status
|
|
```
|
|
|
|
## Struktur skema
|
|
|
|
Migration tabel domain **tidak pernah ada di repo** — skema lama dikelola lewat
|
|
dump `sfacms.sql` yang sengaja di-gitignore. Tujuh migration di bawah ini
|
|
merekonstruksinya dari `app/Models`, Filament Resource, Importer dan Exporter:
|
|
|
|
| Migration | Isi |
|
|
|---|---|
|
|
| `..._000001_create_master_tables` | 16 tabel master (area, brands, product, uom, warehouse, dst.) |
|
|
| `..._000002_create_number_sequence_tables` | number_seq + details, parameters, history |
|
|
| `..._000003_create_employee_and_customer_tables` | employee, customer, attachment, visit log |
|
|
| `..._000004_create_visit_and_task_tables` | schedule visit & task visit (11 tabel) |
|
|
| `..._000005_create_sales_tables` | SO → line → packing → invoice (6 tabel) |
|
|
| `..._000006_create_inventory_tables` | invent journal + invent_trans |
|
|
| `..._000007_create_invent_on_hand_view` | VIEW agregasi stok |
|
|
|
|
Total 44 tabel + 1 view. Tidak ada foreign key constraint — relasi dijaga di
|
|
level aplikasi (Eloquent), tapi tiap kolom relasi sudah diberi index.
|
|
|
|
### invent_on_hand
|
|
|
|
VIEW, bukan tabel — `App\Models\InventOnHand` memakai `$incrementing = false`
|
|
dan `$timestamps = false`. Konvensi tanda di `invent_trans`:
|
|
|
|
| trans_type | qty | Arti |
|
|
|---|---|---|
|
|
| `RESERVE` | negatif | stok dikunci saat SO dikonfirmasi |
|
|
| `RELEASE` | positif | kunci dilepas saat packing dibuat |
|
|
| `ISSUE` | negatif | barang benar-benar keluar |
|
|
| `RECEIPT` | positif | barang masuk lewat journal yang di-post |
|
|
|
|
```
|
|
on_hand = SUM(qty) untuk trans_type selain RESERVE/RELEASE
|
|
reserved = -SUM(qty) untuk RESERVE/RELEASE
|
|
available = on_hand - reserved
|
|
```
|
|
|
|
View dibuat dengan `SQL SECURITY INVOKER`. Tanpa itu MySQL menyimpan akun
|
|
`DEFINER` yang menjalankan migration, dan view gagal "Access denied" di server
|
|
lain yang tidak punya akun tersebut.
|
|
|
|
## Permission (Filament Shield)
|
|
|
|
```bash
|
|
php artisan shield:generate --all --panel=admin # generate 440 permission
|
|
php artisan shield:super-admin --user=1 # jadikan user 1 super admin
|
|
```
|
|
|
|
## Upload file
|
|
|
|
Semua `FileUpload` memakai disk `public` → fisik di `storage/app/public/<dir>`,
|
|
diakses lewat URL `/storage/<dir>/...`.
|
|
|
|
`public/storage` di repo ini adalah **folder nyata yang ter-track git**, bukan
|
|
symlink, jadi `php artisan storage:link` tidak bisa dipakai. Sebagai gantinya
|
|
tiap subfolder upload di-symlink satu per satu:
|
|
|
|
```
|
|
public/storage/backgrounds -> ../../storage/app/public/backgrounds
|
|
public/storage/customer_attachments -> ../../storage/app/public/customer_attachments
|
|
public/storage/files -> ../../storage/app/public/files
|
|
public/storage/photos -> ../../storage/app/public/photos
|
|
public/storage/profile_picture -> ../../storage/app/public/profile_picture
|
|
public/storage/reschedule_picture -> ../../storage/app/public/reschedule_picture
|
|
public/storage/task_attachments -> ../../storage/app/public/task_attachments
|
|
public/storage/user_guide -> ../../storage/app/public/user_guide
|
|
```
|
|
|
|
`public/storage/.gitignore` berisi `*` sehingga symlink ini tidak masuk git.
|
|
|
|
Halaman login butuh minimal satu gambar di `storage/app/public/backgrounds/`
|
|
(plugin filament-backgrounds), kalau kosong error 500 karena `array_rand`
|
|
menerima array kosong.
|
|
|
|
## Backup
|
|
|
|
Dump database ada di `~/sfacms-backup-20260826.sql`.
|
|
|
|
```bash
|
|
mysqldump -uroot --databases sfacms --routines --triggers > backup.sql
|
|
mysql -uroot < backup.sql
|
|
```
|