lamine/license
最新稳定版本:v1.1.2
Composer 安装命令:
composer require lamine/license
包简介
A licensing library for php softwares
README 文档
README
A simple license generator for your projects. Made by Lamine omar.
Installation
composer require lamine/license
Usage
1. Setup the environment variables
Make sure to set the 'APP_NAME' in your .env file.
APP_NAME="Your App Name"
Then add this variables to your .env file. These variables will be used to generate the license. Otherwise the license will not be generated.
COMPANY_URL="https://www.yourwebsite.com/" COMPANY_NAME="Your Company Name" COMPANY_MAIL="your-company@email.com" COMPANY_PHONE="+212 6 00 00 00 00"
Important: Make sure that the COMPANY_URL variable ends with a slash. And leads to a valid url that contains your
licensing system backend.
2. Run Migration
php artisan migrate
This command will create the tables license & timestamps in your database. These tables will be used to store the licenses.
3. setup your home route
Route::get('/', function () { if (Index::validateLicense()) { return view('welcome'); } else { return view('License::LicenseExpired'); } })->name('home');
Or If you are using Inertia, you can do this:
public function index() { if (Index::validateLicense()) { return Inertia::render('Auth/Login'); } else { return view('License::LicenseExpired'); } }
4. Add middleware to your routes
Go to your 'app/Http/Kernel.php' file and add the middleware to your routes.
protected $routeMiddleware = [ . . . 'license-api' => \Lamine\License\Middleware\ApiWare::class, 'license-web' => \Lamine\License\Middleware\WebWare::class, ];
Then add the middleware to your routes.
routes/web.php
Route::group(['middleware' => ['license-web']], function () { // all your web routes here });
routes/api.php
Route::group(['middleware' => ['license-api']], function () { // all your api routes here });
5. Setup the 'app/console/Kernel.php' file
Add this line to the 'schedule' function in your 'app/console/Kernel.php' file.
// check license every week $schedule->call([Index::class, 'checkLicense'])->weekly(); // check time every hour $schedule->call(function () { app()->call([TimeChecker::class, 'checkTime']); })->hourly(); // truncate timestamps table every 24 hours $schedule->call(function () { TimeChecker::truncateTimestamps(); })->daily();
Run the scheduler.
php artisan schedule:work
After finishing all the steps, run development server.
php artisan serve
And go to the home page. If everything is ok, you will see the license expired page.
In this page you can activate your license either by entering the license key or by using a secret key of your company.
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-11