owenmelbz/laravel-stubs
Composer 安装命令:
composer require owenmelbz/laravel-stubs
包简介
Easily store stubs for your project to reuse whenever needed.
关键字:
README 文档
README
We often find outselves having to repeat the same boilerplating when creating new files such as javascript components, blade templates etc.
This package aims to help save your brain cells for the more important things in life (like pizza) by enabling you scaffold the things you're always repeating within a project by taking influence from the other make: commands.
Installation
1- Install via composer composer require owenmelbz/laravel-stubs.
2- The package should use laravels new auto discovery, if not however you can manually register the service provider - typically done inside the app.php providers array e.g OwenMelbz\LaravelStubs\StubsServiceProvider::class.
3- If you're going to be modifying the default stubs, or adding your own stubs, you'll need to publish the config using php artisan vendor:publish --tag=stubs-config which will generate config/template_stubs.php
Usage
Run php artisan make:a {stub} {name} this will generate you a new file, based off the defined stub
The {name} will become the filename and typically the class/component name where the default @placeholder marker is used within the files.
Default stubs
You can view a full list of the default stubs from the config file -> https://github.com/OwenMelbz/Laravel-Stubs/blob/master/src/config/template_stubs.php
Modifying existing stubs
If you want to modify a default stub you can do this in 2 different ways.
The stubs are loaded in a waterfall style - so if you have your own file inside your resources/stubs folder we will use this file instead.
You can either use the same filename that is defined within the stub key of the config e.g vue-component.js and we'll use that. Or you can create a file of any name and change the stub key in a published config file.
If you want to modify every stub in the package, you can publish all the stubs in 1 go using php artisan vendor:publish --tag=stubs-stubs which will place them all in your resources/stubs folder.
Adding custom stubs
You can either publish the default config and modify it, or create your own called template_stubs.php - if you wanted you could even use php artisan make:a config template_stubs and start adding your own.
Creating a new stub requires at minimum, a stub file, an output path, and a name. Below is an example structure
'my-stub' => [ 'stub' => 'my-stub.php', 'output_path' => resource_path('some-folder') ]
It's worth noting that the file extension of the outputted file will match that of the stub file. So in this instance we do not recommend using .stub as your file extension.
During the generation process we parse a token called @placeholder anywhere this marker is within your stub, will get replaced by the name you passed into the command. e.g
This command artisan make:a vue my-component will see a file
Vue.component('@placeholder', { });
and generate my-component.js with the content
Vue.component('my-component', { });
If you want to change @placeholder to something else add the placeholder => '@myothername' to the stub definition within the config.
Contributing community stubs
Please feel free to submit pull requests to add custom stubs, make sure there are no naming conflicts, and keep them as simple as possible.
Typically we adhear to a PSR-2 style for php files, I may modify the code style to make it consistent with submitted stubs.
Notes
This is a very new package, has not been heavily used in the wild, so please bare with me if you stumble across bugs, always add a PR where possible to fix issues as its massively appreciated.
Thank :D
owenmelbz/laravel-stubs 适用场景与选型建议
owenmelbz/laravel-stubs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.11k 次下载、GitHub Stars 达 69, 最近一次更新时间为 2017 年 08 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「templates」 「laravel」 「stubs」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 owenmelbz/laravel-stubs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 owenmelbz/laravel-stubs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 owenmelbz/laravel-stubs 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The Cassandra php driver library IDE stubs which enables autocompletion in modern IDEs.
Shoot aims to make providing data to your templates more manageable
CakePHP 4.x AdminLTE Theme.
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
Default Laravel stubs to our liking.
Laravel 7/8 stubs more consistent with PSR-12 and PHP 7/8
统计信息
- 总下载量: 2.11k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 69
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-08-26