PHPackages                             victoryoalli/laravel-code-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. victoryoalli/laravel-code-generator

ActiveLibrary[Templating &amp; Views](/categories/templating)

victoryoalli/laravel-code-generator
===================================

A PHP Package for Code Generation.

4.0.0(3y ago)757.3k22[1 issues](https://github.com/victoryoalli/laravel-code-generator/issues)MITBladePHP ^8.0

Since Dec 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/victoryoalli/laravel-code-generator)[ Packagist](https://packagist.org/packages/victoryoalli/laravel-code-generator)[ Docs](https://github.com/victoryoalli/laravel-code-generator)[ RSS](/packages/victoryoalli-laravel-code-generator/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (7)Versions (22)Used By (0)

[![Laravel Code Generator](laravel-codegenerator.png)](laravel-codegenerator.png)
=================================================================================

[](#)

[![GitHub release (latest by date)](https://camo.githubusercontent.com/4ca427dcbcf21ccd1cda57d93bdfe1270468b7c1307ea26a3865614483c04cbc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f766963746f72796f616c6c692f6c61726176656c2d636f64652d67656e657261746f72)](https://camo.githubusercontent.com/4ca427dcbcf21ccd1cda57d93bdfe1270468b7c1307ea26a3865614483c04cbc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f766963746f72796f616c6c692f6c61726176656c2d636f64652d67656e657261746f72)[![Packagist PHP Version Support](https://camo.githubusercontent.com/090218f976d44be6291a661823d779466ac070ddbaf039a4f4e486255a5dd68b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f766963746f72796f616c6c692f6c61726176656c2d636f64652d67656e657261746f72)](https://camo.githubusercontent.com/090218f976d44be6291a661823d779466ac070ddbaf039a4f4e486255a5dd68b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f766963746f72796f616c6c692f6c61726176656c2d636f64652d67656e657261746f72)[![GitHub forks](https://camo.githubusercontent.com/5b9af3569dc6fff5ef61095a986894d00dda77c91110ba4e6b431b78b50746f5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f766963746f72796f616c6c692f6c61726176656c2d636f64652d67656e657261746f72)](https://github.com/victoryoalli/laravel-code-generator/network)[![GitHub stars](https://camo.githubusercontent.com/7e689718a92be83a58319bc78db6e8775cc3604459dd19e29cf185e7da78103f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f766963746f72796f616c6c692f6c61726176656c2d636f64652d67656e657261746f72)](https://github.com/victoryoalli/laravel-code-generator/stargazers)[![Packagist Downloads](https://camo.githubusercontent.com/ed849f3fec9a225b742988fe2c9e3bc9f162c8294757672d913672e4cfb36427/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f766963746f72796f616c6c692f6c61726176656c2d636f64652d67656e657261746f72)](https://camo.githubusercontent.com/ed849f3fec9a225b742988fe2c9e3bc9f162c8294757672d913672e4cfb36427/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f766963746f72796f616c6c692f6c61726176656c2d636f64652d67656e657261746f72)

Laravel Code Generator is a PHP Laravel Package that uses [Blade template](https://laravel.com/docs/8.x/blade) engine to generate code for you.

The difference between other code generators is that this one will generate the code exactly as you want it to be, same design, same lines of code.

Demo
----

[](#demo)

- [Video Tutorial Introduction (English) ](https://youtu.be/CgI7eixFexg)

Installation
------------

[](#installation)

Use composer to install Laravel Code Generator.

```
composer require --dev victoryoalli/laravel-code-generator
```

Usage
-----

[](#usage)

### Single file generation

[](#single-file-generation)

```
php artisan code:generate 'App\Models\User' -t 'schema' //prints to command line
php artisan code:generate 'App\Models\User' -t 'schema' -o 'user-schema.json'
```

**Example Output**

```
{
  "name": "User",
  "complete_name": "App\\Models\\User",
  "table": {
    "name": "users",
    "columns": [
      {
        "name": "id",
        "type": "BigInt",
        "length": "",
        "nullable": "",
        "autoincrement": "1",
        "default": ""
      },
      {
        "name": "name",
        "type": "String",
        "length": "255",
        "nullable": "",
        "autoincrement": "",
        "default": ""
      },
      {
        "name": "email",
        "type": "String",
        "length": "255",
        "nullable": "",
        "autoincrement": "",
        "default": ""
      },
      {
        "name": "email_verified_at",
        "type": "DateTime",
        "length": "0",
        "nullable": "1",
        "autoincrement": "",
        "default": ""
      },
      {
        "name": "password",
        "type": "String",
        "length": "255",
        "nullable": "",
        "autoincrement": "",
        "default": ""
      },
      {
        "name": "remember_token",
        "type": "String",
        "length": "100",
        "nullable": "1",
        "autoincrement": "",
        "default": ""
      },
      {
        "name": "created_at",
        "type": "DateTime",
        "length": "0",
        "nullable": "1",
        "autoincrement": "",
        "default": ""
      },
      {
        "name": "updated_at",
        "type": "DateTime",
        "length": "0",
        "nullable": "1",
        "autoincrement": "",
        "default": ""
      }
    ]
  },
  "relations": []
}
```

### Multiple file generator

[](#multiple-file-generator)

First create a custom command like this example

#### Create a Custom Command

[](#create-a-custom-command)

```
php artisan make:command CodeGeneratorCommand --command='code:generator'
```

#### Custom Command

[](#custom-command)

```
