qruto / laravel-flora
使用单条命令安装和更新 Laravel 应用
Requires
- php: ^8.1
- illuminate/bus: ^10.0|^11.0
- illuminate/config: ^10.0|^11.0
- illuminate/console: ^10.0|^11.0
- illuminate/container: ^10.0|^11.0
- illuminate/support: ^10.0|^11.0
- nunomaduro/laravel-desktop-notifier: ^2.8
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- driftingly/rector-laravel: ^1.1
- larastan/larastan: ^2.9
- laravel/pint: ^v1.15
- mockery/mockery: ^1.6
- orchestra/canvas: ^8.12|^9.0
- orchestra/testbench: ^8.0|^9.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- phpunit/phpunit: ^9.6|^10.0
- rector/rector: ^1.0
- spatie/laravel-ray: ^1.36
README
自动设置应用程序的便捷方式。
目标
Flora 的主要目标是定义并自动化 Laravel 应用的设置过程。所有必要的操作都集中在一个地方,以便使应用准备好工作。
包发现、资源构建和发布、运行数据库迁移、缓存等...
🧠🚀 将设置说明的知识放在应用层面。
简介
重新构思并改进了 Laravel Initializer。重新思考,改进,美化,重命名。
Flora 允许您通过一条命令使 Laravel 应用投入运行。使用默认设置或定义自定义操作链来安装或更新应用。
在获取新应用时运行 install
以准备将其部署到新的环境。
- 在
git clone
之后
在每次依赖或源代码更改后运行 update
。
- 在
composer install|update
之后 - 在
git pull|checkout|megre|...
之后 - 在部署脚本中
- 在 CI/CD 流水中
它将处理其余工作。
支持
从2月24日起,很遗憾,我没有任何商业工作,也没有固定的居住地或长期规划的能力。然而,我有一个更大的愿望,即为世界各地的人们创造有用的解决方案。这使我现在感觉好多了。
GitHub 赞助者资料 已准备就绪!在那里您可以找到当前工作、未来计划、目标和梦想...您的星标使我的每一天都更加快乐 ❤️ ⭐ 赞助将使我们能够更加和平地生活,并继续为您的工作。
我会非常感激提及或真诚的“谢谢”。
💳 直接赞助到储蓄罐(使用卡片或 Apple Pay/Google Pay)。
安装
通过 Composer
composer require qruto/laravel-flora
使用
将 readme 文件中的 安装 部分替换为
php artisan install
通过以下方式刷新应用程序状态
php artisan update
ℹ️ 指令取决于当前 环境。包已预定义适用于大多数情况的操作。
在详细输出模式下查看详细信息
php artisan app:update -v
您可以通过将 @php artisan update
命令添加到应用程序 composer.json
脚本 post-autoload-dump
部分并从 post-update-cmd
部分中删除默认的 vendor:publish
命令来自动化更新过程。 update
命令将为您处理资源发布。
使用以下方式设置
php artisan flora:setup --script
composer.json
变更
"post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", - "@php artisan package:discover --ansi" + "@php artisan update" ], - "post-update-cmd": [ - "@php artisan vendor:publish --tag=laravel-assets --ansi --force" - ],
注册任务调度器
条件
- 任何已注册的调度任务
- 执行了安装过程
- 应用程序处于生产环境
然后您将提示添加 cron 条目,以 每分钟运行任务调度器。
配置
要为每个环境自定义指令,您需要发布设置文件。
php artisan flora:setup
此命令将创建 routes/setup.php
文件,其中包含针对 local
和 production
环境的预定义指令。
use Qruto\Flora\Run; App::install('local', fn (Run $run) => $run ->command('key:generate') ->command('migrate') ->command('storage:link') ->script('build') ); App::install('production', fn (Run $run) => $run ->command('key:generate', ['--force' => true]) ->command('migrate', ['--force' => true]) ->command('storage:link') ->script('cache') ->script('build') ); App::update('local', fn (Run $run) => $run ->command('migrate') ->command('cache:clear') ->script('build') ); App::update('production', fn (Run $run) => $run ->script('cache') ->command('migrate', ['--force' => true]) ->command('cache:clear') ->command('queue:restart') ->script('build') );
您可以随意更改它或添加特定环境,如 staging
。
`build` 和 `cache` 脚本详细信息
build
脚本包含构建资源的命令
npm install npm run build
cache
脚本提供通用应用程序缓存
php artisan route:cache php artisan config:cache php artisan event:cache
此外,它将为配置资源发布创建 config/flora.php
return [ /* |-------------------------------------------------------------------------- | Force Assets Publish |-------------------------------------------------------------------------- | | Force publish assets on every installation or update. By default, assets | will always be force published, which would completely automate the | setup. Switch it to false if you want to manually publish assets. | For example if you prefer to commit them. */ 'force_publish' => true, /* |-------------------------------------------------------------------------- | Publishable Assets |-------------------------------------------------------------------------- | | List of assets that will be published during installation or update. | Most of required assets detects on the way. If you need specific | tag or provider, feel free to add it to the array. */ 'assets' => [ 'laravel-assets', ], ];
如果您只需要自定义资源发布,则可以仅发布配置文件
php artisan vendor:publish --tag=flora-config
侧边包支持
Flora 会自动检测几个包,以便在安装或更新时执行必要的操作。例如:发布Vapor UI资源,生成IDE帮助文件,终止Horizon工作进程等。
支持
即将推出
自定义脚本
在服务提供者的 boot
方法中覆盖或定义自定义脚本
Run::newScript('cache', fn (Run $run) => $run ->command('route:cache') ->command('config:cache') ->command('event:cache') ->command('view:cache') );
可用操作
$run ->command('command') // Run artisan command ->script('build') // Perform custom script ->exec('process') // Execute external process ->job(new JobClass) // Dispatch job ->call(fn () => makeSomething()) // Call callable function ->notify('Done!') // Send notification
升级
有关详细信息,请参阅 UPGRADING
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG
测试
composer test
贡献
有关详细信息,请参阅 CONTRIBUTING 和 CONDUCT
安全性
如果您发现任何安全相关的问题,请通过电子邮件 bro@qruto.to 而不是使用问题跟踪器
致谢
感谢 Nuno Maduro 为 laravel-desktop-notifier 包做出贡献,该包将桌面通知引入了Laravel。
许可证
MIT许可证(MIT)。有关更多信息,请参阅 许可证文件