无法在 Illuminate\Support\Facades\Hash 中使用 Hash::make('plain-text')
unable to use Hash::make('plain-text') in Illuminate\Support\Facades\Hash
我正在使用 Eloquent 通过 slim 框架进行数据库调用,这是我的 composer.json
{
"require": {
"slim/slim": "3.0",
"illuminate/database": "^6.8",
"monolog/monolog": "^2.0"
}
我想使用 Illuminate\Support\Facades\Hash 中可用的 Hash::make();但它给出了这个错误
测试代码:
<?php
use Illuminate\Support\Facades\Hash;
require 'vendor/autoload.php';
require 'app.php';
$container = $app->getContainer();
//boot eloquent connection
$capsule = new Capsule;
$capsule->addConnection($container['settings']['db']);
$capsule->setAsGlobal();
$capsule->bootEloquent();
//pass the connection to global container (created in previous article)
$container['db'] = function ($container){
return $capsule;
};
echo Hash::make('wonder');
我尝试了作曲家更新,但没有解决。
如何解决这个问题?有什么解决办法吗?
这是一个工作示例。
首先,您需要安装:
composer require illuminate/config
composer require illuminate/database
composer require illuminate/hashing
代码示例如下:
<?php
use Illuminate\Config\Repository;
use Illuminate\Container\Container as IlluminateContainer;
use Illuminate\Hashing\HashManager;
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\Hash;
use Illuminate\Database\Capsule\Manager as Capsule;
require_once __DIR__ . '/../vendor/autoload.php';
$container = new IlluminateContainer();
Facade::setFacadeApplication($container);
$container->singleton('config', function () {
return new Repository();
});
$container->singleton('hash', function ($app) {
return new HashManager($app);
});
$container->singleton('hash.driver', function ($app) {
return $app['hash']->driver();
});
//boot eloquent connection
$capsule = new Capsule();
//$capsule->addConnection($container['settings']['db']);
$capsule->setAsGlobal();
$capsule->bootEloquent();
echo Hash::make('wonder');
PS: Laravel 有自己的容器实现。
我正在使用 Eloquent 通过 slim 框架进行数据库调用,这是我的 composer.json
{
"require": {
"slim/slim": "3.0",
"illuminate/database": "^6.8",
"monolog/monolog": "^2.0"
}
我想使用 Illuminate\Support\Facades\Hash 中可用的 Hash::make();但它给出了这个错误
<?php
use Illuminate\Support\Facades\Hash;
require 'vendor/autoload.php';
require 'app.php';
$container = $app->getContainer();
//boot eloquent connection
$capsule = new Capsule;
$capsule->addConnection($container['settings']['db']);
$capsule->setAsGlobal();
$capsule->bootEloquent();
//pass the connection to global container (created in previous article)
$container['db'] = function ($container){
return $capsule;
};
echo Hash::make('wonder');
我尝试了作曲家更新,但没有解决。
如何解决这个问题?有什么解决办法吗?
这是一个工作示例。
首先,您需要安装:
composer require illuminate/config
composer require illuminate/database
composer require illuminate/hashing
代码示例如下:
<?php
use Illuminate\Config\Repository;
use Illuminate\Container\Container as IlluminateContainer;
use Illuminate\Hashing\HashManager;
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\Hash;
use Illuminate\Database\Capsule\Manager as Capsule;
require_once __DIR__ . '/../vendor/autoload.php';
$container = new IlluminateContainer();
Facade::setFacadeApplication($container);
$container->singleton('config', function () {
return new Repository();
});
$container->singleton('hash', function ($app) {
return new HashManager($app);
});
$container->singleton('hash.driver', function ($app) {
return $app['hash']->driver();
});
//boot eloquent connection
$capsule = new Capsule();
//$capsule->addConnection($container['settings']['db']);
$capsule->setAsGlobal();
$capsule->bootEloquent();
echo Hash::make('wonder');
PS: Laravel 有自己的容器实现。