xgenious/installer

Laravel 脚本安装包

v1.6.0 2024-09-03 10:01 UTC

README

这是一个 Laravel 包,用于通过图形界面安装器轻松安装 xgenious 脚本 image

安装

使用 composer 安装此包

composer require xgenious/installer

发布配置文件:

php artisan vendor:publish --provider="Xgenious\Installer\InstallerServiceProvider" --tag="config"

app\Http\Kernel.php 文件中添加中间件:

\Xgenious\Installer\Http\Middleware\InstallerMiddleware::class

example
  protected $middleware = [
        /* Laravel defult middleware */
        \Xgenious\Installer\Http\Middleware\InstallerMiddleware::class
    ];

配置值说明

# config/installer.php

return [
    'app_name' => 'Fundorex', //app name 
    'super_admin_role_id' => 3, // super admin role id
    'admin_model' => \App\Admin::class, //admin modal 
    'admin_table' => 'admins', //admin table
    'multi_tenant' => false,
    'author' => 'xgenious', // envato author username
    'product_key' => '8de1f072836b127749b7aa2b575ffc0002ade20e', //product key from xgenious license server
    'php_version' => '8.1', //minimum required php version
    'extensions' => ['BCMath', 'Ctype', 'JSON', 'Mbstring', 'OpenSSL', 'PDO', 'pdo_mysql', 'Tokenizer', 'XML', 'cURL', 'fileinfo'], //required php extensions
    'website' => 'https://xgenious.com', //author website url
    'email' => 'support@xgenious.com', //support url
    'env_example_path' => public_path('env-sample.txt'), //env-sample.txt file locaation, env will be generate based on this file contenant
    'broadcast_driver' => 'log', // default config value 
    'cache_driver' => 'file', // default config value 
    'queue_connection' => 'sync', // default config value 
    'mail_port' => '587', // default config value 
    'mail_encryption' => 'tls', // default config value 
    'model_has_roles' => true,
    'bundle_pack' => false, //if the product has bundle pack
    'bundle_pack_key' => 'dsfasd', //bundle pack product key
];

从旧安装程序迁移

删除 install 文件夹,并从根 index.php 文件中删除 install 文件夹的重定向

所需的最小 .env 文件

以下是最小 .env 文件的示例。

APP_NAME=Fundorex
APP_ENV=production
APP_KEY=base64:8e5wSFpua5CzuHhXJEaJHcpRFBR2nqLAV0zTURuXgLA=
APP_DEBUG=false
APP_URL=http://fundorex.test/

运行测试

要为此包运行测试套件,请按照以下步骤操作

确保已安装此包及其依赖项

composer install

将包的 phpunit.xml.dist 文件复制到 phpunit.xml

cp phpunit.xml.dist phpunit.xml

使用 PHPUnit 运行测试

./vendor/bin/phpunit

或者,如果您已设置 Composer 脚本,可以使用

composer test

要生成覆盖率报告,运行

./vendor/bin/phpunit --coverage-html coverage

这将生成一个位于覆盖率目录中的 HTML 覆盖率报告。

注意

默认情况下,测试使用内存中的 SQLite 数据库。如果您需要使用不同的数据库进行测试,请相应地更新 phpunit.xml 文件。

某些测试可能需要设置特定的环境变量。请检查 phpunit.xml 文件,并在本地环境中或在 phpunit.xml 文件中设置任何必要的变量。

如果在运行测试时遇到任何问题,请确保所有依赖项都已正确安装,并且您的 PHP 环境满足包的要求。

编写新测试

在添加新功能或修复错误时,请添加相应的测试用例。将新测试文件放在 tests 目录中,遵循现有结构

单元测试放在 tests/Unit 功能测试放在 tests/Feature

确保您的测试类扩展 Xgenious\Installer\Tests\TestCase.

如果您需要添加新的测试依赖项,请将它们添加到 composer.json 文件中的 require-dev 部分。

用法

当您的 Laravel 应用程序中找不到 .env 文件时,此包将自动显示安装向导。