Tuesday, May 6, 2025

Laravel 12 + Filament: .env Set to MySQL, But Laravel Still Uses SQLite? Here's the Fix

 

If you're developing a Laravel 12 application using Filament Admin Panel, you might run into a confusing issue:

 

    You've already updated your .env file to use mysql, but Laravel still tries to connect using sqlite.

 

This can be frustrating, especially when you're certain the .env file is correctly configured.

📌 Your .env Might Look Like This:

 

DB_CONNECTION=mysql

DB_HOST=127.0.0.1

DB_PORT=3306

DB_DATABASE=mysql

DB_USERNAME=mysql

DB_PASSWORD=password

 

But when you run:

 

php artisan tinker

>>> env('DB_CONNECTION')

You get:

null

Or:

"sqlite"

 

🔍 Root Cause: Laravel Is Using Cached Configuration

 

Laravel uses configuration caching to boost performance. If you’ve previously run:

 

php artisan config:cache

 

Laravel will no longer read the .env file directly, and instead use the cached version stored in:

 

bootstrap/cache/config.php

 

Solution: Remove the Cached Configuration

 

To fix this, simply delete the cached config file and clear Laravel’s caches.

1. Delete the cached config file

 

Run this in the root directory of your Laravel project:

 

rm bootstrap/cache/config.php

 

2. Clear Laravel’s config and cache

 

Then run:

 

php artisan config:clear

php artisan cache:clear

 

3. Test Again

 

Open Tinker:

 

php artisan tinker

>>> env('DB_CONNECTION')

 

You should now see:

 

"mysql"

 

You can also confirm it by running:

 

>>> DB::connection()->getDatabaseName();

 

🧠 Additional Notes

 

    Make sure your .env file is named correctly and located in the root folder of your project.

 

    Also verify your config/database.php is not hardcoded to 'sqlite'.

 

It should use the environment variable:

 

'default' => env('DB_CONNECTION', 'mysql'),

 

🎯 Conclusion

 

If Laravel continues to use sqlite despite your .env being set to mysql, the most likely reason is that it’s still using cached configuration. Just delete bootstrap/cache/config.php and clear the config cache — problem solved.

 

Hope this helps!

Fixing "The POST method is not supported for route admin/login" in Laravel 12 with Filament 3.2 on aaPanel

When deploying a Laravel 12 application using Filament 3.2 on an Ubuntu 24 server with aaPanel, you might run into the following error:

The POST method is not supported for route admin/login. Supported methods: GET, HEAD.

✅ The Problem

This error typically doesn't appear when you're working locally. Everything might work perfectly on your local development machine, but as soon as you deploy it to a production server using aaPanel, you face this issue.

The core of the problem lies in how Nginx (via aaPanel) handles URL rewriting. Laravel relies on correctly passing all requests to index.php, especially when handling POST requests like login attempts.

By default, if Nginx is not properly configured, it may only handle GET requests correctly while ignoring POST routes (such as admin/login from Filament).

✅ The Solution

To solve this issue, you need to modify the Nginx configuration for your site via aaPanel. Specifically, update the URL rewrite rules to ensure all request methods (GET, POST, etc.) are correctly forwarded to Laravel's index.php.

Update your Nginx rewrite configuration to the following:

location / {
try_files $uri $uri/ /index.php$is_args$query_string;
}

location ^~ /livewire {
try_files $uri $uri/ /index.php?$query_string;
}

 

✅ How to Apply the Fix in aaPanel

  1. Log in to your aaPanel dashboard.

  2. Go to Website > select your Laravel domain > click Config.

  3. Scroll down to find the URL rewrite section.

  4. Replace the existing rewrite rules with the ones above.

  5. Save the configuration and reload Nginx.

✅ Why This Works

  • The try_files directive ensures that any request (including POST) will be passed to index.php if no file or directory is found that matches the URI.

  • Laravel’s routing system will then properly handle the request, including POST requests to /admin/login.

  • The /livewire block ensures Filament’s Livewire components also work correctly.

✅ Final Notes

  • Always clear your Laravel cache after deployment:

    php artisan config:clear
    php artisan route:clear
    php artisan view:clear
    php artisan cache:clear


Monday, April 23, 2018

Setting mikrotik supaya beberapa port mempunyai IP yang sama

postingan supaya kalo lupa bisa lihat blog.
Kebetulan dikantor ada mikrotik rb 1100 ah, itu barang ada sekitar 13 ethernet dan 2 grup. Rencananya saya mau buat grup 2 yaitu eth6-eth10 mempunyai ip yang sama misalnya 192.168.77.1-254. Ternyata caranya mudah saja, tinggal setting seperti biasa misalnya eth1 untuk indihome dan eth10 untuk lan. Kalo sudah tinggal setting di eth6-eth9 dengan setingan yang sama yaitu merubah master port ip-address menjadi eth10 seperti gambar di bawah:


Local web server centos tiba-tiba lambat

Pagi-pagi masuk kantor sudah dihadapi masalah yang tidak biasa, yaitu semua aplikasi berbasis web yang di install di centos pada lambat waktu dibuka. Akhirnya beberapa pengecekan saya lakukan:
1. cek memory centos aman (free)
2. cek mikrotik aman
3. Cek hub (capek juga ngecek 2 lantai) dan ini dia masalahnya..... <-

Ternyata ada yang error hub nya.... ada yang ganti adaptor hub menggunakan 12 volt yang seharusnya menggunakan 5 volt saja.... Alhasil semua lampu indikator menyala dan berpengaruh ke lambatnya jaringan lokal.

Saturday, February 21, 2015

Perangkap untuk tikus atau tikus got yang berkeliaran di rumah

Binatang ini sangat mengganggu dan membuat kotor serta menimbulkan bau yang tidak sedap. Kadang kalo malam malah masuk ke kamar dal loncat-loncat di tempat tidur dan coba lihat di kolong tempat tidur dan lemari pasti banyak kotoran.
Cara ini saya temukan dengan tidak sengaja waktu renovasi rumah. Kebetulan di dinding bersandar bebeapa triplek, dan ada tikus got yang berlarian kemudian bersembunyi di balik triplek. Kemudian saya jepit tikus itu di triplek dan saya pukul. Hal ini terjadi sampai beberapa kali sampai tidak ada tikus got yang berkeliaran.
Demikian pengalaman dari saya, mudah2 an bermanfaat.

Thursday, February 19, 2015

Cara Ampuh Usir Tikus di Rumah Sampai Ke celahnya

Tikus di rumah memang sangat menggaggu penghuninya. Berbagai cara pun sudah saya tempuh mulai dari racun tikus, tapi tikusnya tidak mau makan. Kemudian lem tikus yang cuman 2 kai pakai, tapi lengketnya kemana2. Kemudian jebakan tikus yang 1 atau 2 kali pakai saja.
Sampai suatu saat ada kucing agak besar datang ke rumah meminta makan, kemudian saya kasih makan dia sedikit, dia datang setiap hari namun saya kasih makan 2 hari sekali (supaya tidak manja). Dan ternyata benar setiap malam di atas plafon terjadi perburuan tikus (uda kaya orang tawuran berisiknya), hal ini terjadi sampai beberapa bulan dan alhamdulillah tikus pun lenyap dari peredaran.. Hore...

Intinya:
1. Pelihara kucing
2. Jangan beri makan banyak2, biar dia juga berburu tikus
3. kasih dia jalan menuju plafon

Saturday, January 10, 2015

Mengatasi Epson inkjet Papper jamm Teruss

Saya mendapat servisan printer epson inkjet yang mengalami masalah papper jamm terus, padahal tidak ada kertas atau sobekan kertas. Hal ini sempat membingungkan saya, karena error terjadi setelah printer dinyalakan. 
Akhirnya dengan penuh gundah, saya tanyakan pada forum teknisi printer, namun belum berhasil. Kemudian saya tanyakan pada facebook epson dan belum berhasil.