I'm trying to implement the hashids library in my project, I'm not using composer
My function is simple like this:
function generate_hash_id($id){
require("../libs/Hashids.php");
$hashids = new Hashids\Hashids('teste');
$hash = $hashids->encrypt($id);
return $hash;
}
But it is returning 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:
SoIunderstandthatthelibraryisnotinthispath
,butthat'sthewayitis!
Followingthetipsof@guilherme,Iremovedtherequire
fromwithinfunction
.
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