lotfixyz/laravel-smartdetect

适用于Laravel的开发助手。

dev-master 2020-01-23 14:18 UTC

This package is auto-updated.

Last update: 2024-09-25 18:24:30 UTC


README

适用于Laravel的开发助手。

在Laravel 5.8和6.2上测试过

安装

使用以下命令通过composer安装此包:

composer require lotfixyz/laravel-smartdetect

执行composer命令后,将自动加载添加到你的composer.json文件中的autoload/psr-4部分,并确保运行composer dump-autoload

"Lotfixyz\\Smartdetect\\": "vendor/lotfixyz/laravel-smartdetect/src"

例如:

...
"autoload": {
    "psr-4": {
        ...
        "Lotfixyz\\Smartdetect\\": "vendor/lotfixyz/laravel-smartdetect/src"
    },
    ...
},
...

最后,将服务提供者添加到config/app.php文件中的providers数组中。

Lotfixyz\Smartdetect\SmartdetectServiceProvider::class,

安装 --dev

若仅要在开发系统上安装此包,请在composer命令中添加--dev标志。

composer require --dev lotfixyz/laravel-smartdetect

执行composer命令后,将自动加载添加到你的composer.json文件中的autoload-dev/psr-4部分,并确保运行composer dump-autoload

"Lotfixyz\\Smartdetect\\": "vendor/lotfixyz/laravel-smartdetect/src"

例如:

...
"autoload-dev": {
    "psr-4": {
        ...
        "Lotfixyz\\Smartdetect\\": "vendor/lotfixyz/laravel-smartdetect/src"
    },
    ...
},
...

最后,你可以在app/Providers/AppServiceProvider.php文件的register()方法中添加以下代码,而不是在config/app.php文件中添加服务提供者:

if ('production' !== $this->app->environment())
{
    $this->app->register(\Lotfixyz\Smartdetect\SmartdetectServiceProvider::class);
}

这将在非生产环境中允许你的应用程序加载Smartdetect。

重要提示

不要忘记在修改composer.json文件后运行composer dump-autoload

发布

你可以发布配置文件以控制默认值和设置。

运行php artisan vendor:publish并选择Lotfixyz\Smartdetect\SmartdetectServiceProvider

环境文件

你也可以选择性地将以下行添加到你的.env文件中。

SMARTDETECT_TURNED_OFF=false
SMARTDETECT_DEBUG_MODE="${APP_DEBUG}"
SMARTDETECT_INVOLVE_CONFIG=true
SMARTDETECT_INVOLVE_DOMAIN=true
SMARTDETECT_INVOLVE_IP=true
SMARTDETECT_INVOLVE_REQUEST=true
SMARTDETECT_INVOLVE_USER=true

使用方法

只需使用此示例。

$smartdetect = new SmartdetectClass();
$smartdetect->bind_ip('94.232.175.55');
$smartdetect->bind_domain('lotfi.xyz', SmartdetectClass::DOMAIN_TYPE_ENTIRE);
$smartdetect->bind_domain('.xyz', SmartdetectClass::DOMAIN_TYPE_EXTENSION);
$smartdetect->bind_domain('lotfi.', SmartdetectClass::DOMAIN_TYPE_NAME);
$smartdetect->bind_request('with_value', 110);
$smartdetect->bind_request('without_value');
$smartdetect->bind_user('demo', SmartdetectClass::USER_TYPE_EMAIL);
$smartdetect->bind_user('2', SmartdetectClass::USER_TYPE_ID);
$smartdetect->make();
dd((array)$smartdetect->result);

注意

文档和新功能即将推出...

许可协议

Laravel Smartdetect是开源软件,许可协议为MIT许可协议