PHPackages                             dannyvilla/artisan-commands - 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. [CLI &amp; Console](/categories/cli)
4. /
5. dannyvilla/artisan-commands

ActiveLibrary[CLI &amp; Console](/categories/cli)

dannyvilla/artisan-commands
===========================

This package provides a set of artisan commands for Laravel

v2.0.1(1mo ago)47.5k↑119.7%3MITPHPPHP &gt;=8.1.0

Since Sep 13Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/Danny-Villa/artisan-commands)[ Packagist](https://packagist.org/packages/dannyvilla/artisan-commands)[ RSS](/packages/dannyvilla-artisan-commands/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (2)Versions (10)Used By (0)

Davinet/Artisan-commands
========================

[](#davinetartisan-commands)

This package provides a set of new artisan commands for Laravel

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

[](#installation)

Use the package manager [composer](https://getcomposer.org/) to install dannyvilla/artisan-commands

```
composer require dannyvilla/artisan-commands
```

### Configuration

[](#configuration)

Publish the package config when you want to change where models are discovered or where TypeScript definitions are written:

```
php artisan vendor:publish --provider="Davinet\ArtisanCommand\ArtisanCommandServiceProvider"
```

This creates `config/artisan-commands.php` in your application. The relevant options are:

```
return [
    'models_path' => 'app/Models/',

    'transform' => [
        'type' => 'interface',
        'output' => 'resouces/js/types',
    ],
];
```

- `models_path` tells the package where your Eloquent models live. Change it if your application keeps models outside `app/Models`.
- `transform.type` controls the generated TypeScript declaration style. Use `interface` to generate `export interface IUser { ... }`, or `type` to generate `export type IUser = { ... }`.
- `transform.output` controls the output folder, relative to the application base path. Change it to match your frontend structure, such as `resources/js/types` or `resources/ts/generated`.

Usage
-----

[](#usage)

### Model annotate command

[](#model-annotate-command)

Add generated PHPDoc annotations to Eloquent models from database columns and typed relation methods.

```
php artisan model:annotate
```

Annotate one model by basename, fully qualified class, or configured model path:

```
php artisan model:annotate User
php artisan model:annotate App\\Models\\User
```

Preview changes without writing files:

```
php artisan model:annotate --dry-run
```

The command scans `artisan-commands.models_path`, inspects each model table, and writes a generated section inside the model class PHPDoc:

```
/**
 * @generated model annotations
 * @property int $id
 * @property string $email
 * @property-read \Illuminate\Database\Eloquent\Collection $posts
 * @property-read \App\Models\Profile|null $profile
 * @end-generated model annotations
 */
class User extends Model
{
}
```

On later runs, only the generated section between the markers is replaced, so your handwritten class documentation is kept. Relation annotations are generated from public, parameterless model methods with an Eloquent relation return type, such as `posts(): HasMany` or `profile(): HasOne`.

### TypeScript transform command

[](#typescript-transform-command)

Transform PHP classes, models, resources, and enums marked with the `TypeScriptTransform` attribute into TypeScript definitions.

```
php artisan typescript:transform
```

Definitions are written to `resouces/js/types/index.d.ts` by default. Publish the config to change `transform.type` to `interface` or `type`, and `transform.output` to another output folder.

Only PHP types marked with `#[TypeScriptTransform]` are transformed. The command scans your application classes, reflects each marked type, and writes one TypeScript definition file. Related transformed types can also be included when they are referenced by model relations, resource responses, or typed properties.

The command supports four kinds of PHP types:

- **Plain PHP classes:** public non-static properties are mapped to TypeScript properties.
- **Eloquent models:** database columns are mapped first, including their database type and nullability. Relation methods such as `profile(): HasOne` are added as optional nested properties. If database inspection is not possible, the command falls back to `@property` annotations, then `$fillable`, then public properties.
- **JSON resources:** the TypeScript shape is inferred from the array returned by `toArray()`, not from the resource class properties.
- **Enums:** enum cases become a TypeScript `const` object and a value-union type.

#### Classes and models

[](#classes-and-models)

```
use Davinet\ArtisanCommand\Attributes\TypeScriptTransform;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;

#[TypeScriptTransform]
class User extends Model
{
    public function profile(): HasOne
    {
        return $this->hasOne(Profile::class);
    }
}
```

For a model, the command inspects the model table and maps each column:

- numeric columns become `number`
- boolean columns become `boolean`
- date, time, text, uuid, enum, and string columns become `string`
- JSON and array columns become `Record`
- nullable database columns become optional TypeScript properties
- non-null database columns, like most IDs, become required TypeScript properties

Typed Eloquent relation methods are included too. For example, `profile(): HasOne` adds `profile?: IProfile`, while `posts(): HasMany` adds `posts?: IPost[]`.

If the database cannot be inspected, model properties are resolved in this fallback order:

1. `@property`, `@property-read`, and `@property-write` annotations
2. `$fillable` fields
3. public non-static class properties

#### Resources

[](#resources)

Resources are transformed from their `toArray()` response instead of their class properties.

```
use Davinet\ArtisanCommand\Attributes\TypeScriptTransform;
use Illuminate\Http\Resources\Json\JsonResource;

#[TypeScriptTransform]
class UserResource extends JsonResource
{
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'role' => $this->role,
        ];
    }
}
```

For a resource, the command creates a sample backing model when it can infer one from the resource name, such as `UserResource` to `User`. It then calls `toArray()` and maps the returned keys and values to TypeScript. Nested arrays become inline object types, nested resources become their own transformed types, and resource collections become arrays of the collected resource type.

#### Enums

[](#enums)

```
use Davinet\ArtisanCommand\Attributes\TypeScriptTransform;

#[TypeScriptTransform]
enum UserRole: string
{
    case ADMIN = 'admin';
    case USER = 'user';
}
```

This generates:

```
export const UserRoles = { ADMIN: 'admin', USER: 'user' } as const;

export type UserRole = (typeof UserRoles)[keyof typeof UserRoles];
```

For an enum, the exported const preserves the original PHP case names and backed values. The exported type is the union of the const values, so `UserRole` is equivalent to `'admin' | 'user'`.

### Repository command

[](#repository-command)

Generate an empty repository file:

```
php artisan make:repository UserRepository
```

Generate a repository for a model:

```
php artisan make:repository UserRepository --model=User
```

You may also pass a fully qualified model class:

```
php artisan make:repository UserRepository --model=App\Models\User
```

### Service command

[](#service-command)

Generate a service class:

```
php artisan make:service PayPalPaymentService
```

Generate a service class with a repository dependency:

```
php artisan make:service UserService UserRepository
```

### View command

[](#view-command)

Generate an empty view:

```
php artisan make:view folder.subfolder.view
```

Generate a view with a layout:

```
php artisan make:view folder.subfolder.view --layout=app
```

### Lang command

[](#lang-command)

Generate a new locale file:

```
php artisan make:lang myFilename --locale=es
```

Generate a new JSON locale file:

```
php artisan make:lang --locale=es --json
```

### Class command

[](#class-command)

Generate a class:

```
php artisan make:class App\Handlers\UserHandlers
```

You can use a dot (`.`) as separator:

```
php artisan make:class App.Handlers.UserHandlers --separator=.
```

Generate a trait:

```
php artisan make:class App\Traits\MyTrait --kind=trait
```

Generate an interface:

```
php artisan make:class App\Contracts\IClassable --kind=interface
```

### File command

[](#file-command)

Generate a generic file:

```
php artisan make:file folder.subfolder1.subfolder2.filename --ext=php
```

Contributing
------------

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License
-------

[](#license)

[MIT](https://choosealicense.com/licenses/mit/)

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance91

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 93.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~305 days

Recently: every ~560 days

Total

9

Last Release

43d ago

Major Versions

v0.0.1 → v1.02019-11-07

v1.2.1 → v2.0.02026-05-12

PHP version history (2 changes)v0.0.1PHP &gt;=7.0.0

v2.0.0PHP &gt;=8.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/00139237ed3773e10d2866f46f8f17b214b489595f9d124dc613cc06e61612cb?d=identicon)[Danny Villa](/maintainers/Danny%20Villa)

---

Top Contributors

[![Danny-Villa](https://avatars.githubusercontent.com/u/49371019?v=4)](https://github.com/Danny-Villa "Danny-Villa (30 commits)")[![danny-villa-schoolap](https://avatars.githubusercontent.com/u/117824004?v=4)](https://github.com/danny-villa-schoolap "danny-villa-schoolap (2 commits)")

---

Tags

artisan-commandslaravellaravel-package

### Embed Badge

![Health badge](/badges/dannyvilla-artisan-commands/health.svg)

```
[![Health](https://phpackages.com/badges/dannyvilla-artisan-commands/health.svg)](https://phpackages.com/packages/dannyvilla-artisan-commands)
```

###  Alternatives

[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)[ronasit/laravel-entity-generator

Provided console command for generating entities.

2053.1k](/packages/ronasit-laravel-entity-generator)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21318.6k3](/packages/ecotone-laravel)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3416.9k](/packages/duncanmcclean-statamic-cargo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
