placetopay / app-version
提供有关当前应用程序的信息
2.9.1
2024-04-04 13:23 UTC
Requires
- php: >=7.4 | ^8.0 | ^8.1 | ^8.2
- ext-curl: *
- ext-json: *
- laravel/framework: ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.3.0
- orchestra/testbench: ^4.0|^5.0|^6.0
- phpunit/phpunit: ^8.0|^10.0
This package is auto-updated.
Last update: 2024-09-04 14:08:45 UTC
README
该 placetopay/app-version
软件包提供了一种方法,可以知道您的应用程序当前部署了哪个版本。
安装
使用 composer 安装
composer require placetopay/app-version ^2.0
该软件包将自动注册自身,并应在您的本地环境中正常工作
如果您使用 Sentry,请按照以下步骤配置部署和版本到您的报告中
- 发布配置文件
php artisan vendor:publish --provider="PlacetoPay\AppVersion\VersionServiceProvider"
- 在
config/app-version.php
中设置您的环境变量
return [ 'sentry' => [ /* * The sentry auth token used to authenticate with Sentry Api * Create tokens here at account level https://sentry.io/settings/account/api/auth-tokens/ * Or here at organization level https://sentry.io/settings/your-organization/developer-settings/ */ 'auth_token' => env('APP_VERSION_SENTRY_AUTH'), /* * The organization name this project belongs to, you can find out the * organization at https://sentry.io/settings/ */ 'organization' => env('APP_VERSION_SENTRY_ORGANIZATION', 'placetopay'), /* * The repository name of this project. Repositories are added in sentry as integrations. * You must add your (Github|Bitbucket) integration at https://sentry.io/settings/your-organization/integrations/ * and then add the repositories you want to track commits */ 'repository' => env('APP_VERSION_SENTRY_REPOSITORY'), /* * The name of this project in Sentry Dashboard * You can find out the project name at https://sentry.io/settings/your-organization/projects/ */ 'project' => env('APP_VERSION_SENTRY_PROJECT'), ], 'newrelic' => [ /* * The NewRelic Rest API Key, you can found it on the following URL when you are logged in * https://rpm.newrelic.com/api/explore/application_deployments/create */ 'api_key' => env('APP_VERSION_NEWRELIC_API_KEY'), /* * The NewRelic application id, you can get it from the URL in the APM */ 'application_id' => env('APP_VERSION_NEWRELIC_APPLICATION_ID'), ], /* * The current deployed version, will be read from version file * generated by `php artisan app-version:create ...` command */ 'version' => \PlacetoPay\AppVersion\VersionFile::readSha(), /* * The value of query param token to be able showed the deployed version. */ 'token' => env('APP_VERSION_TOKEN', 'delivery'), ];
- 使用以下设置设置
config/sentry.php
文件
return [ 'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')), // capture release as git sha 'release' => \PlacetoPay\AppVersion\VersionFile::readSha(), 'breadcrumbs' => [ // Capture Laravel logs in breadcrumbs 'logs' => true, // Capture SQL queries in breadcrumbs 'sql_queries' => true, // Capture bindings on SQL queries logged in breadcrumbs 'sql_bindings' => true, // Capture queue job information in breadcrumbs 'queue_info' => true, ], ];
用法
您可以通过访问 https://yourapp.com/version
来查看版本信息
Envoyer 钩子
使用像 Envoyer 这样的工具进行部署,一旦部署,就不再有 git 源可用,因此我们使用可用的 sha、项目和分支信息创建一个包含这些信息的文件
- 在“激活新版本”操作中创建一个部署钩子,这个钩子必须在运行 config:cache 或 optimize 命令之前运行
cd {{ release }} php artisan app-version:create --sha={{ sha }} --time={{ time }} --project={{ project }} --branch={{ branch }}
这将在 storage/app/app-version.json
生成您的版本文件
- 如果您正在与 Sentry 或 NewRelic 集成 Releases/Deployments/Issues,请添加这些钩子,以便 Sentry 和 NewRelic 可以跟踪您的部署。它应在运行优化或配置缓存之后运行。
cd {{ release }}
php artisan app-version:create-release
php artisan app-version:create-deploy
从 CLI 了解您的版本
如果您使用 tinker,可以使用以下命令获取版本信息
访问使用用法步骤 1 生成的版本信息
config('app-version.version.sha');
访问 sha
PlacetoPay\AppVersion\VersionFile::readSha()