Laravel password hashes through native php
My code is like this :
echo Hash::make('12345');
error : Fatal error: Class 'Hash' not found in C...
How to call the hash class in laravel through native php
Thank you
You probably use namespaced controler action, so you should do this:
echo \Hash::make('12345');
Using Hash without backslash means accessing a class from a current namespace ie. \App\Http\Controller\Hash.
Do the above or import the namespace
use Hash;
I run the code in the php native or php regular, not in laravel. So, whether it can use the hash laravel in regular php?
@chris97pl, @bashy, It looks like it only works in laravel, in native php not working
Oh you're not using Laravel? I'm confused.
@bashy, Yes, I'm not using laravel. I use php native. But, I want to use hash laravel. If it can be done?
@Juukie, But it's not hash laravel. Although in php native, I wanted to use the hash laravel. If it can be done?
You can require the illuminate/hashing in your composer.json. It'll pull in https://packagist.org/packages/illuminate/hashing.
$hasher = new Illuminate\Hashing\BcryptHasher();
$hash = $hasher->make('foo');
But you could also just manually copy the BcryptHasher.php file if you don't need the Service Provider stuff.
Well, simply put you can't. You have to either add dependency as suggested or simply make a call to
$hash = password_hash($valueToHash, PASSWORD_BCRYPT, 10);
Please or to participate in this conversation.