-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from binafy/1.x
1.x
- Loading branch information
Showing
15 changed files
with
713 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2 | ||
|
||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: dependabot-auto-merge | ||
on: pull_request_target | ||
|
||
permissions: | ||
pull-requests: write | ||
contents: write | ||
|
||
jobs: | ||
dependabot: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.actor == 'dependabot[bot]' }} | ||
steps: | ||
|
||
- name: Dependabot metadata | ||
id: metadata | ||
uses: dependabot/[email protected] | ||
with: | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
compat-lookup: true | ||
|
||
- name: Auto-merge Dependabot PRs for semver-minor updates | ||
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}} | ||
run: gh pr merge --auto --merge "$PR_URL" | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: Auto-merge Dependabot PRs for semver-patch updates | ||
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}} | ||
run: gh pr merge --auto --merge "$PR_URL" | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: Auto-merge Dependabot PRs for Action major versions when compatibility is higher than 90% | ||
if: ${{steps.metadata.outputs.package-ecosystem == 'github_actions' && steps.metadata.outputs.update-type == 'version-update:semver-major' && steps.metadata.outputs.compatibility-score >= 90}} | ||
run: gh pr merge --auto --merge "$PR_URL" | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: "Run Tests" | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: [8.0, 8.1, 8.2, 8.3] | ||
laravel: [9.*, 10.*, 11.*] | ||
dependency-version: [prefer-lowest, prefer-stable] | ||
include: | ||
- laravel: 11.* | ||
testbench: 9.* | ||
pest-plugin-laravel: 2.3.0 | ||
|
||
- laravel: 10.* | ||
testbench: 8.* | ||
pest-plugin-laravel: 2.0.0 | ||
|
||
- laravel: 9.* | ||
testbench: 7.* | ||
pest-plugin-laravel: 1.4.0 | ||
|
||
exclude: | ||
- laravel: 11.* | ||
php: 8.0 | ||
|
||
- laravel: 11.* | ||
php: 8.1 | ||
|
||
- laravel: 10.* | ||
php: 8.0 | ||
|
||
- laravel: 9.* | ||
php: 8.3 | ||
|
||
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv | ||
coverage: none | ||
|
||
- name: Install dependencies | ||
run: | | ||
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "pestphp/pest-plugin-laravel:${{ matrix.pest-plugin-laravel }}" --no-interaction --no-update | ||
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction | ||
- name: Execute tests | ||
run: vendor/bin/pest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: update changelog | ||
|
||
on: | ||
release: | ||
types: [released] | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
update: | ||
permissions: | ||
contents: write | ||
uses: laravel/.github/.github/workflows/update-changelog.yml@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ composer.lock | |
.idea | ||
.phpunit.result.cache | ||
coverage | ||
tests/App/new-test.php | ||
tests/Feature/test.stub |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
## Laravel Stub | ||
|
||
<img src="https://banners.beyondco.de/Laravel%20Stub.png?theme=dark&packageManager=composer+require&packageName=binafy%2Flaravel-stub&pattern=yyy&style=style_1&description=Generate+stub+files+very+easy+in+Laravel+framework&md=1&showWatermark=0&fontSize=100px&images=https%3A%2F%2Flaravel.com%2Fimg%2Flogomark.min.svg" alt="laravel-stub-banner"> | ||
|
||
[](https://packagist.org/packages/binafy/laravel-stub) | ||
[](https://packagist.org/packages/binafy/laravel-stub) | ||
[](https://packagist.org/packages/binafy/laravel-stub) | ||
[](https://packagist.org/packages/binafy/laravel-stub) | ||
[](https://github.com/binafy/laravel-stub/actions/workflows/tests.yml) | ||
|
||
- [Introduction](#introduction) | ||
- [Requirements](#requirements) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Create a stub file](#create-a-stub-file) | ||
- [How to use Laravel Stub](#how-using-laravel-stub) | ||
- [`from`](#from) | ||
- [`to`](#to) | ||
- [`name`](#name) | ||
- [`ext`](#ext) | ||
- [`replace`](#replace) | ||
- [`replaces`](#replaces) | ||
- [`download`](#download) | ||
- [`generate`](#generate) | ||
- [Contributors](#contributors) | ||
- [Security](#security) | ||
- [Changelog](#changelog) | ||
- [License](#license) | ||
|
||
<a name="introduction"></a> | ||
## Introduction | ||
|
||
The Laravel-Stub package enhances the development workflow in Laravel by providing a set of customizable stubs. Stubs are templates used to scaffold code snippets for various components like models, controllers, and migrations. With Laravel-Stub, developers can easily tailor these stubs to match their project's coding standards and conventions. This package aims to streamline the code generation process, fostering consistency and efficiency in Laravel projects. Explore the customization options and boost your development speed with Laravel-Stub. | ||
|
||
<a name="requirements"></a> | ||
## Requirements | ||
|
||
*** | ||
- ```PHP >= 8.0``` | ||
- ```Laravel >= 9.0``` | ||
|
||
|
||
| Version/Laravel | L9 | L10 | L11 | | ||
|-----------------|--------------------|--------------------|--------------------| | ||
| 1.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | ||
|
||
<a name="installation"></a> | ||
## Installation | ||
|
||
You can install the package with Composer: | ||
|
||
```bash | ||
composer require binafy/laravel-stub | ||
``` | ||
|
||
You don't need to publish anything. | ||
|
||
<a name="usage"></a> | ||
## Usage | ||
|
||
<a name="create-a-stub-file"></a> | ||
### Create a stub file | ||
First of all, create a stub file called `model.stub`: | ||
|
||
```bash | ||
touch model.stub | ||
``` | ||
|
||
Add some code to that, like this: | ||
|
||
```php | ||
<?php | ||
|
||
namespace {{ NAMESPACE }}; | ||
|
||
class {{ CLASS }} | ||
{ | ||
|
||
} | ||
``` | ||
|
||
<a name="how-using-laravel-stub"></a> | ||
### How to use Laravel Stub | ||
|
||
You may use Laravel Stub, you need to use the `LaravelStub` facade: | ||
|
||
```php | ||
use Binafy\LaravelStub\Facades\LaravelStub; | ||
|
||
LaravelStub::class; | ||
``` | ||
|
||
<a name="from"></a> | ||
### `from` | ||
|
||
First thing, you need to use the `from` method to give the stub path: | ||
|
||
```php | ||
LaravelStub::from(__DIR__ . 'model.stub'); | ||
``` | ||
|
||
<a name="to"></a> | ||
### `to` | ||
|
||
So, you need to determine the destination path of the stub file: | ||
|
||
```php | ||
LaravelStub::from(__DIR__ . 'model.stub') | ||
->to(__DIR__ . '/App'); | ||
``` | ||
|
||
<a name="name"></a> | ||
### `name` | ||
|
||
You can determine the stub file but also attention don't write the stub extension: | ||
|
||
```php | ||
LaravelStub::from(__DIR__ . 'model.stub') | ||
->to(__DIR__ . '/App') | ||
->name('new-model'); | ||
``` | ||
|
||
<a name="ext"></a> | ||
### `ext` | ||
|
||
You can determine the stub extension: | ||
|
||
```php | ||
LaravelStub::from(__DIR__ . 'model.stub') | ||
->to(__DIR__ . '/App') | ||
->name('new-model') | ||
->ext('php'); | ||
``` | ||
|
||
<a name="replace"></a> | ||
### `replace` | ||
|
||
The `replace` method takes two parameters, the first one is the key (variable) and the second one is the value. The value will be replaced with the variable: | ||
|
||
```php | ||
LaravelStub::from(__DIR__ . 'model.stub') | ||
->to(__DIR__ . '/App') | ||
->name('new-model') | ||
->ext('php') | ||
->replace('NAMESPACE', 'App'); | ||
``` | ||
|
||
<a name="replaces"></a> | ||
### `replaces` | ||
|
||
The `replaces` method takes an array. If you want to replace multiple variables you can use this method: | ||
|
||
```php | ||
LaravelStub::from(__DIR__ . 'model.stub') | ||
->to(__DIR__ . '/App') | ||
->name('new-model') | ||
->ext('php') | ||
->replaces([ | ||
'NAMESPACE' => 'App', | ||
'CLASS' => 'Milwad' | ||
]); | ||
``` | ||
|
||
<a name="download"></a> | ||
### `download` | ||
|
||
If you want to download the stub file, you can use the `download` method: | ||
|
||
```php | ||
LaravelStub::from(__DIR__ . 'model.stub') | ||
->to(__DIR__ . '/App') | ||
->name('new-model') | ||
->ext('php') | ||
->replaces([ | ||
'NAMESPACE' => 'App', | ||
'CLASS' => 'Milwad' | ||
]) | ||
->download(); // Return download response | ||
``` | ||
|
||
<a name="generate"></a> | ||
### `generate` | ||
|
||
The important method is `generate`. To generate the stub file at the end you need to use the `generate` method to generate stub file: | ||
|
||
```php | ||
LaravelStub::from(__DIR__ . 'model.stub') | ||
->to(__DIR__ . '/App') | ||
->name('new-model') | ||
->ext('php') | ||
->replaces([ | ||
'NAMESPACE' => 'App', | ||
'CLASS' => 'Milwad' | ||
]) | ||
->generate(); | ||
``` | ||
|
||
> **_NOTE:_** Don't use the `download` and `generate` methods in one chain. | ||
The final file will be like this (`new-model.php`): | ||
|
||
```php | ||
<?php | ||
|
||
namespace App; | ||
|
||
class Milwad | ||
{ | ||
|
||
} | ||
``` | ||
|
||
<a name="contributors"></a> | ||
## Contributors | ||
|
||
Thanks to all the people who contributed. [Contributors](https://github.com/binafy/laravel-stub/graphs/contributors). | ||
|
||
<a href="https://github.com/binafy/laravel-stub/graphs/contributors"><img src="https://opencollective.com/laravel-stub/contributors.svg?width=890&button=false" /></a> | ||
|
||
<a name="security"></a> | ||
## Security | ||
|
||
If you discover any security-related issues, please email `[email protected]` instead of using the issue tracker. | ||
|
||
<a name="chanelog"></a> | ||
## Changelog | ||
|
||
The changelog can be found in the `CHANGELOG.md` file of the GitHub repository. It lists the changes, bug fixes, and improvements made to each version of the Laravel User Monitoring package. | ||
|
||
<a name="license"></a> | ||
## License | ||
|
||
The MIT License (MIT). Please see [License File](https://github.com/binafy/laravel-stub/blob/1.x/LICENSE) for more information. |
Oops, something went wrong.