uniqid( ) fonksiyonunu inceleyebilirsin, sunucu seviyesinde daha önce hiç kullanılmamış id üretir.

https://www.php.net/manual/tr/function.uniqid.php