0
I’m trying to implement the library hashids in my project, I am not using the composer
My job is as simple as that:
function generate_hash_id($id){
require("../libs/Hashids.php");
$hashids = new Hashids\Hashids('teste');
$hash = $hashids->encrypt($id);
return $hash;
}
But it’s coming back 500 Internal Server Error
I call the function inside an iterator
for($i = 0; $i < 10, $i++){
generate_hash_id($i);
}
The structure of my project:
From what I understand you’re accusing that the library is not in this path
, but that’s the way!
Following the @Uilherme tips, I removed the require
from within the function
.
require("../libs/Hashids.php");
function generate_hash_id($id){
$hashids = new Hashids\Hashids('teste');
$hash = $hashids->encrypt($id);
return $hash;
}
for($i = 0; $i < 10, $i++){
generate_hash_id($i);
}
Now the error that returns:
Fatal error: Uncaught Error: Call to Undefined method Hashids Hashids::Encrypt() in /usr/share/Nginx/www/api/Automatic/index.php:16 Stack trace: #0 /usr/share/Nginx/www/api/Automatic/index.php(110): generate_hash_id(1) #1 {main} thrown in /usr/share/Nginx/www/api/Automatic/index.php on line 16
Friend trade require for require_once
– Guilherme Nascimento