{"id":15293903,"url":"https://github.com/binafy/laravel-stub","last_synced_at":"2026-04-19T10:04:07.235Z","repository":{"id":225536000,"uuid":"766225835","full_name":"binafy/laravel-stub","owner":"binafy","description":"Generate stub files very easily in the Laravel framework","archived":false,"fork":false,"pushed_at":"2025-03-01T16:15:04.000Z","size":103,"stargazers_count":89,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"1.x","last_synced_at":"2025-04-03T23:08:46.412Z","etag":null,"topics":["binafy","filesystem","framework","generate-stub","laravel","laravel-framework","laravel-package","laravel-stub","laravel-stub-binafy","laravel-stub-package","laravel-stubs","laravelstub","milwad","php","stub","stub-files"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/binafy/laravel-stub","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/binafy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-02T17:18:14.000Z","updated_at":"2025-03-21T01:42:03.000Z","dependencies_parsed_at":"2024-07-07T20:47:52.127Z","dependency_job_id":"462b9fd9-3f7d-47ac-8e92-cffbaca24e2f","html_url":"https://github.com/binafy/laravel-stub","commit_stats":null,"previous_names":["binafy/laravel-stub"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binafy%2Flaravel-stub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binafy%2Flaravel-stub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binafy%2Flaravel-stub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binafy%2Flaravel-stub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binafy","download_url":"https://codeload.github.com/binafy/laravel-stub/tar.gz/refs/heads/1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625491,"owners_count":21135513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binafy","filesystem","framework","generate-stub","laravel","laravel-framework","laravel-package","laravel-stub","laravel-stub-binafy","laravel-stub-package","laravel-stubs","laravelstub","milwad","php","stub","stub-files"],"created_at":"2024-09-30T16:53:37.304Z","updated_at":"2026-04-19T10:04:02.193Z","avatar_url":"https://github.com/binafy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Laravel Stub\n\n\u003cimg src=\"https://banners.beyondco.de/Laravel%20Stub.png?theme=dark\u0026packageManager=composer+require\u0026packageName=binafy%2Flaravel-stub\u0026pattern=yyy\u0026style=style_1\u0026description=Generate+stub+files+very+easy+in+Laravel+framework\u0026md=1\u0026showWatermark=0\u0026fontSize=100px\u0026images=https%3A%2F%2Flaravel.com%2Fimg%2Flogomark.min.svg\" alt=\"laravel-stub-banner\"\u003e\n\n[![PHP Version Require](https://img.shields.io/packagist/dependency-v/binafy/laravel-stub/php.svg)](https://packagist.org/packages/binafy/laravel-stub)\n[![Latest Stable Version](https://img.shields.io/packagist/v/binafy/laravel-stub.svg)](https://packagist.org/packages/binafy/laravel-stub)\n[![Total Downloads](https://img.shields.io/packagist/dt/binafy/laravel-stub.svg)](https://packagist.org/packages/binafy/laravel-stub)\n[![License](https://img.shields.io/packagist/l/binafy/laravel-stub.svg)](https://packagist.org/packages/binafy/laravel-stub)\n[![Passed Tests](https://github.com/binafy/laravel-stub/actions/workflows/tests.yml/badge.svg)](https://github.com/binafy/laravel-stub/actions/workflows/tests.yml)\n\n- [Introduction](#introduction)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Create a stub file](#create-a-stub-file)\n    - [How to use Laravel Stub](#how-using-laravel-stub)\n    - [`from`](#from)\n    - [`to`](#to)\n    - [`name`](#name)\n    - [`ext`](#ext)\n    - [`replace`](#replace)\n    - [`replaces`](#replaces)\n    - [`moveStub`](#move-stub)\n    - [`conditions`](#conditions)\n    - [`download`](#download)\n    - [`generate`](#generate)\n    - [`generateForce`](#generate-force)\n    - [`generateIf`](#generate-if)\n    - [`generateUnless`](#generate-unless)\n- [Contributors](#contributors)\n- [Security](#security)\n- [Changelog](#changelog)\n- [License](#license)\n- [Donate](#donate)\n\n\u003ca name=\"introduction\"\u003e\u003c/a\u003e\n## Introduction\n\nThe 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.\n\n\u003ca name=\"requirements\"\u003e\u003c/a\u003e\n## Requirements\n\n***\n- ```PHP \u003e= 8.0```\n- ```Laravel \u003e= 9.0```\n\n\n| Version/Laravel | L9                 | L10                | L11                |\n|-----------------|--------------------|--------------------|--------------------|\n| 1.0             | :white_check_mark: | :white_check_mark: | :white_check_mark: |\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n## Installation\n\nYou can install the package with Composer:\n\n```bash\ncomposer require binafy/laravel-stub\n```\n\nYou don't need to publish anything.\n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n## Usage\n\n\u003ca name=\"create-a-stub-file\"\u003e\u003c/a\u003e\n### Create a stub file\nFirst of all, create a stub file called `model.stub`:\n\n```bash\ntouch model.stub\n```\n\nAdd some code to that, like this:\n\n```php\n\u003c?php\n\nnamespace {{ NAMESPACE }};\n\nclass {{ CLASS }}\n{\n    \n}\n```\n\n\u003ca name=\"how-using-laravel-stub\"\u003e\u003c/a\u003e\n### How to use Laravel Stub\n\nYou may use Laravel Stub, you need to use the `LaravelStub` facade:\n\n```php\nuse Binafy\\LaravelStub\\Facades\\LaravelStub;\n\nLaravelStub::class;\n```\n\n\u003ca name=\"from\"\u003e\u003c/a\u003e\n### `from`\n\nFirst thing, you need to use the `from` method to give the stub path:\n\n```php\nLaravelStub::from(__DIR__ . 'model.stub');\n```\n\n\u003ca name=\"to\"\u003e\u003c/a\u003e\n### `to`\n\nSo, you need to determine the destination path of the stub file:\n\n```php\nLaravelStub::from(__DIR__ . 'model.stub')\n    -\u003eto(__DIR__ . '/App');\n```\n\n\u003ca name=\"name\"\u003e\u003c/a\u003e\n### `name`\n\nYou can determine the stub file but also attention don't write the stub extension:\n\n```php\nLaravelStub::from(__DIR__ . 'model.stub')\n    -\u003eto(__DIR__ . '/App')\n    -\u003ename('new-model');\n```\n\n\u003ca name=\"ext\"\u003e\u003c/a\u003e\n### `ext`\n\nYou can determine the stub extension:\n\n```php\nLaravelStub::from(__DIR__ . 'model.stub')\n    -\u003eto(__DIR__ . '/App')\n    -\u003ename('new-model')\n    -\u003eext('php');\n```\n\n\u003ca name=\"replace\"\u003e\u003c/a\u003e\n### `replace`\n\nThe `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:\n\n```php\nLaravelStub::from(__DIR__ . 'model.stub')\n    -\u003eto(__DIR__ . '/App')\n    -\u003ename('new-model')\n    -\u003eext('php')\n    -\u003ereplace('NAMESPACE', 'App');\n```\n\n\u003ca name=\"replaces\"\u003e\u003c/a\u003e\n### `replaces`\n\nThe `replaces` method takes an array. If you want to replace multiple variables you can use this method:\n\n```php\nLaravelStub::from(__DIR__ . 'model.stub')\n    -\u003eto(__DIR__ . '/App')\n    -\u003ename('new-model')\n    -\u003eext('php')\n    -\u003ereplaces([\n        'NAMESPACE' =\u003e 'App',\n        'CLASS' =\u003e 'Milwad'\n    ]);\n```\n\n\u003ca name=\"move-stub\"\u003e\u003c/a\u003e\n### `moveStub`\n\nBy default, `Laravel Stub` creates a copy from your stub file and moves it to the destination path. If you want to move the current stub file, you can use the `moveStub` method:\n\n```php\nLaravelStub::from(__DIR__ . 'model.stub')\n    -\u003eto(__DIR__ . '/App')\n    -\u003ename('new-model')\n    -\u003eext('php')\n    -\u003ereplaces([\n        'NAMESPACE' =\u003e 'App',\n        'CLASS' =\u003e 'Milwad'\n    ])\n    -\u003emoveStub();\n```\n\nAfter running this code, the `model.stub` didn't exist.\n\n\u003ca name=\"conditions\"\u003e\u003c/a\u003e\n### `conditions`\n\nThe `conditions` method allows you to define conditional blocks within your stub files.\nYou can specify conditions that determine whether certain parts of the stub should be included or excluded based on provided values or closures.\n\n```php\nLaravelStub::from(__DIR__ . 'model.stub')\n    -\u003eto(__DIR__ . '/App')\n    -\u003ename('new-model')\n    -\u003eext('php')\n    -\u003ereplaces([\n        'NAMESPACE' =\u003e 'App',\n        'CLASS' =\u003e 'Milwad'\n    ])\n    -\u003econditions([\n        'hasController' =\u003e true,\n        'hasController' =\u003e fn() =\u003e false, // or with closure\n    ])\n    -\u003egenerate();\n```\n\n\u003e NOTE: Ensure that your stub files contain the appropriate conditional placeholders (e.g., {{ if isEnabled }}) to utilize this method effectively.\n\nYour stub code should looks like this:\n\n```php\n\u003c?php\n\nnamespace {{ NAMESPACE }};\n\nclass {{ CLASS }}\n{\n    {{ if hasController }}\n    public function controller()\n    {\n        // Controller logic here\n    }\n    {{ endif }}\n}\n```\n\n\u003ca name=\"download\"\u003e\u003c/a\u003e\n### `download`\n\nIf you want to download the stub file, you can use the `download` method:\n\n```php\nLaravelStub::from(__DIR__ . 'model.stub')\n    -\u003eto(__DIR__ . '/App')\n    -\u003ename('new-model')\n    -\u003eext('php')\n    -\u003ereplaces([\n        'NAMESPACE' =\u003e 'App',\n        'CLASS' =\u003e 'Milwad'\n    ])\n    -\u003edownload(); // Return download response\n```\n\n\u003ca name=\"generate\"\u003e\u003c/a\u003e\n### `generate`\n\nThe important method is `generate`. To generate the stub file at the end you need to use the `generate` method to generate stub file:\n\n```php\nLaravelStub::from(__DIR__ . 'model.stub')\n    -\u003eto(__DIR__ . '/App')\n    -\u003ename('new-model')\n    -\u003eext('php')\n    -\u003ereplaces([\n        'NAMESPACE' =\u003e 'App',\n        'CLASS' =\u003e 'Milwad'\n    ])\n    -\u003egenerate();\n```\n\n\u003e **_NOTE:_**  Don't use the `download` and `generate` methods in one chain.\n\nThe final file will be like this (`new-model.php`):\n\n```php\n\u003c?php\n\nnamespace App;\n\nclass Milwad\n{\n    \n}\n```\n\n\u003ca name=\"generate-force\"\u003e\u003c/a\u003e\n### `generateForce`\n\nIf you want to generate a stub file and overwrite it if it exists, you can use the `generateForce` method:\n\n```php\nLaravelStub::from(__DIR__ . 'model.stub')\n    -\u003eto(__DIR__ . '/App')\n    -\u003ename('new-model')\n    -\u003eext('php')\n    -\u003ereplaces([\n        'NAMESPACE' =\u003e 'App',\n        'CLASS' =\u003e 'Milwad'\n    ])\n    -\u003egenerateForce();\n```\n\n\u003ca name=\"generate-if\"\u003e\u003c/a\u003e\n### `generateIf`\n\nIf you want to generate a stub file if given boolean expression evaluates to `true`, you can use the `generateIf` method:\n\n```php\nLaravelStub::from(__DIR__ . 'model.stub')\n    -\u003eto(__DIR__ . '/App')\n    -\u003ename('new-model')\n    -\u003eext('php')\n    -\u003ereplaces([\n        'NAMESPACE' =\u003e 'App',\n        'CLASS' =\u003e 'Milwad'\n    ])\n    -\u003egenerateIf(true);\n```\n\n\u003ca name=\"generate-unless\"\u003e\u003c/a\u003e\n### `generateUnless`\n\nIf you want to generate a stub file if given boolean expression evaluates to `false`, you can use the `generateIf` method:\n\n```php\nLaravelStub::from(__DIR__ . 'model.stub')\n    -\u003eto(__DIR__ . '/App')\n    -\u003ename('new-model')\n    -\u003eext('php')\n    -\u003ereplaces([\n        'NAMESPACE' =\u003e 'App',\n        'CLASS' =\u003e 'Milwad'\n    ])\n    -\u003egenerateUnless(true);\n```\n\n\u003ca name=\"contributors\"\u003e\u003c/a\u003e\n## Contributors\n\nThanks to all the people who contributed. [Contributors](https://github.com/binafy/laravel-stub/graphs/contributors).\n\n\u003ca href=\"https://github.com/binafy/laravel-stub/graphs/contributors\"\u003e\u003cimg src=\"https://opencollective.com/laravel-stub/contributors.svg?width=890\u0026button=false\" /\u003e\u003c/a\u003e\n\n\u003ca name=\"security\"\u003e\u003c/a\u003e\n## Security\n\nIf you discover any security-related issues, please email `binafy23@gmail.com` instead of using the issue tracker.\n\n\u003ca name=\"chanelog\"\u003e\u003c/a\u003e\n## Changelog\n\nThe 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.\n\n\u003ca name=\"license\"\u003e\u003c/a\u003e\n## License\n\nThe MIT License (MIT). Please see [License File](https://github.com/binafy/laravel-stub/blob/1.x/LICENSE) for more information.\n\n## Donate\n\nIf this package is helpful for you, you can buy a coffee for me :) ❤️\n\n- Iraninan Gateway: https://daramet.com/milwad_khosravi\n- Paypal Gateway: SOON\n- MetaMask Address: `0xf208a562c5a93DEf8450b656c3dbc1d0a53BDE58`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinafy%2Flaravel-stub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinafy%2Flaravel-stub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinafy%2Flaravel-stub/lists"}