gp10devhts/laravel-beer
Composer 安装命令:
composer require gp10devhts/laravel-beer
包简介
A Laravel package for developers who love Nile beer and clean code.
README 文档
README
A Laravel package for developers who love Nile beer and clean code. Enjoy coding with a cold brew in hand, and let Laravel do the heavy lifting.
Made for Nugsoft's Start of Year 2025. 🍻
Installation:
- Grab a Nile beer 🍻.
- Install Composer: Composer Installation
- Run:
composer require gp10devhts/laravel-beer
Enjoy your code, enjoy your beer!
Usage
This package provides a BeerService that you can use to get a friendly beer-related message.
1. Dependency Injection
You can inject Gp10devhts\LaravelBeer\BeerService into your controllers or other classes:
<?php namespace App\Http\Controllers; use Gp10devhts\LaravelBeer\BeerService; // Import the service use Illuminate\Http\Request; class YourController extends Controller { protected $beerService; public function __construct(BeerService $beerService) { $this->beerService = $beerService; } public function showBeerMessage(Request $request) { $message = $this->beerService->getColdNileBeer(); // Example: return to a view return view('your-view', ['beerMessage' => $message]); // Or, return as JSON // return response()->json(['message' => $message]); } }
2. Using app() or resolve() Helpers
You can also resolve the service directly from Laravel's service container:
// Using the app() helper $beerService = app(Gp10devhts\LaravelBeer\BeerService::class); $message = $beerService->getColdNileBeer(); // echo $message; // "Here's a cold Nile Beer for you!" // Or using the resolve() helper $anotherBeerServiceInstance = resolve(Gp10devhts\LaravelBeer\BeerService::class); $anotherMessage = $anotherBeerServiceInstance->getColdNileBeer(); // echo $anotherMessage; // "Here's a cold Nile Beer for you!"
The BeerService is registered as a singleton, so you'll always receive the same instance within a single request lifecycle.
3. Using the Artisan Command
This package also comes with a fun Artisan command to serve you a virtual beer message directly in your terminal!
To use it, simply run:
php artisan beer:serve
This will display a random beer-related quote, a fun message, or the classic "Here's a cold Nile Beer for you!" message.
More Fun Commands:
-
php artisan beer:cheers {name?}- Sends a cheers message. You can optionally provide a name for a personalized touch.
- Example:
php artisan beer:cheers Jules - Output: "🍻 Cheers, Jules! May your code flow as smoothly as a well-poured pint."
-
php artisan beer:wisdom- Shares a piece of beer-related wisdom or coding philosophy.
- Example:
php artisan beer:wisdom - Output: "🍺 Beer Wisdom: Code without tests is like a beer without a head. Something's missing."
-
php artisan beer:happy-hour- Announces happy hour or displays a fun related message, sometimes with ASCII art.
- Example:
php artisan beer:happy-hour - Output: "It's Beer O'Clock Somewhere! 🍻 Why not take a short break?" (or ASCII art)
-
php artisan beer:empty-keg- Clears your application's view and application caches, with themed messages.
- Example:
php artisan beer:empty-keg - Output: "🛢️ Time to empty the old kegs..." followed by Artisan output from
view:clearandcache:clear.
-
php artisan beer:open- Serves your Laravel project using
php artisan serve, but with some encouraging beer-themed messages. - Example:
php artisan beer:open - Output: "🍺 Tapping a fresh keg and firing up the server..." followed by the standard
php artisan serveoutput.
- Serves your Laravel project using
-
php artisan beer:test {--passthru options}- Runs your application's tests using
php artisan test. It displays some beer-themed ASCII art and messages before running the tests. - You can pass options to the underlying
artisan testcommand (e.g.,--coverage, or a test file/filter if supported by your setup). - Example:
php artisan beer:test - Example with options:
php artisan beer:test --coverage - Output: Beer ASCII art, themed messages, and then the standard
php artisan testoutput.
- Runs your application's tests using
gp10devhts/laravel-beer 适用场景与选型建议
gp10devhts/laravel-beer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 05 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 gp10devhts/laravel-beer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gp10devhts/laravel-beer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-21