PHPackages                             aariow/artisan-api - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. aariow/artisan-api

ActiveProject[HTTP &amp; Networking](/categories/http)

aariow/artisan-api
==================

Execute Laravel Artisan commands via REST APIs and HTTP requests safely.

v1.2.1-beta(3y ago)1271[1 issues](https://github.com/arfar-x/artisan-api/issues)MITPHPPHP ^8.0.2

Since Jul 22Pushed 2y ago1 watchersCompare

[ Source](https://github.com/arfar-x/artisan-api)[ Packagist](https://packagist.org/packages/aariow/artisan-api)[ RSS](/packages/aariow-artisan-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (6)Used By (0)

Artisan Api
===========

[](#artisan-api)

Artisan commands with HTTP

---

[![Packagist PHP Version Support](https://camo.githubusercontent.com/75489dba90af8a18453eba48a123fe53cde12f27c9fb39c5bac0be7612ab5908/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f616172696f772f6172746973616e2d617069)](https://camo.githubusercontent.com/75489dba90af8a18453eba48a123fe53cde12f27c9fb39c5bac0be7612ab5908/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f616172696f772f6172746973616e2d617069) [![GitHub](https://camo.githubusercontent.com/81f697913dd2481c47853f31c761aae3459ebaf81cbc9128e4f668afd23c5798/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f616172696f772f6172746973616e2d617069)](https://camo.githubusercontent.com/81f697913dd2481c47853f31c761aae3459ebaf81cbc9128e4f668afd23c5798/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f616172696f772f6172746973616e2d617069) [![Packagist Version](https://camo.githubusercontent.com/2e84508de9d0120444817a82b4c9fbe0d56fd1a4ea5a33bb1c1a1316235865df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616172696f772f6172746973616e2d6170693f6c6162656c3d76657273696f6e)](https://camo.githubusercontent.com/2e84508de9d0120444817a82b4c9fbe0d56fd1a4ea5a33bb1c1a1316235865df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616172696f772f6172746973616e2d6170693f6c6162656c3d76657273696f6e) [![Packagist Downloads](https://camo.githubusercontent.com/86383b652d1acdf02ed6628b2eb03d0428d701fba203fa83eaf8a53aa4396a06/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f616172696f772f6172746973616e2d6170693f6c6162656c3d5061636b6167697374253230646f776e6c6f616473)](https://camo.githubusercontent.com/86383b652d1acdf02ed6628b2eb03d0428d701fba203fa83eaf8a53aa4396a06/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f616172696f772f6172746973616e2d6170693f6c6162656c3d5061636b6167697374253230646f776e6c6f616473) [![GitHub all releases](https://camo.githubusercontent.com/2eb8bf52784c825f43b0157d490adf61e269d4087aff8b64ea876067984c110b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f616172696f772f6172746973616e2d6170692f746f74616c3f6c6162656c3d476974687562253230646f776e6c6f616473)](https://camo.githubusercontent.com/2eb8bf52784c825f43b0157d490adf61e269d4087aff8b64ea876067984c110b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f616172696f772f6172746973616e2d6170692f746f74616c3f6c6162656c3d476974687562253230646f776e6c6f616473) [![GitHub repo size](https://camo.githubusercontent.com/f12c4dc40f38fa26fde8548c118c84d63f54d06ae9e4dd641cc6373bec0669ab/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f616172696f772f6172746973616e2d6170693f6c6162656c3d73697a65)](https://camo.githubusercontent.com/f12c4dc40f38fa26fde8548c118c84d63f54d06ae9e4dd641cc6373bec0669ab/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f616172696f772f6172746973616e2d6170693f6c6162656c3d73697a65)

[![Linkedin URL](https://camo.githubusercontent.com/ef9f5e664f0da8344f6c28aff2ea5b612e032c962c48220c5275ededa5100e25/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c696e6b6564696e2d616172696f772d626c75653f7374796c653d736f6369616c266c6f676f3d6c696e6b6564696e2675726c3d6c696e6b6564696e2e636f6d2f696e2f616172696f77)](https://camo.githubusercontent.com/ef9f5e664f0da8344f6c28aff2ea5b612e032c962c48220c5275ededa5100e25/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c696e6b6564696e2d616172696f772d626c75653f7374796c653d736f6369616c266c6f676f3d6c696e6b6564696e2675726c3d6c696e6b6564696e2e636f6d2f696e2f616172696f77)

**There might be some times you wanted to execute an Artisan command, but you did not have access to shell or SSH. Here we brought REST API solution for you.**

**You are able to run Artisan commands by REST APIs easily.**

*'README.md need to be updated'*

### Table of contents

[](#table-of-contents)

- **[Get Started](#get-started)**
- **[Endpoints](#endpoints)**
    - **[Routes](#routes)**
    - **[Responses](#responses)**
        - **[Successful](#successful)**
        - **[Not Found](#not-found)**
        - **[Invalid Arguments format](#invalid-arguments-format)**
        - **[Invalid Options format](#invalid-options-format)**
    - **[Forbidden Routes](#forbidden-routes)**
    - **[Authentication](#authentication)**
- **[Configurations](#configurations)**
    - **[API Prefix and HTTP Method](#api-prefix-and-http-method)**
    - **[Auto Run](#auto-run)**
- **[Security](#security)**
    - **[Middlewares](#middlewares)**
- **[Useful tips](#useful-tips)**
- **[Todo](#todo)**

### Get Started

[](#get-started)

To use this package, you should install it alongside [Laravel v9.21](https://laravel.com/) and [PHP v8.0](https://php.net) or higher.

you can install it via [Composer package manager](https://getcomposer.org/):

```
composer require aariow/artisan-api --dev
```

Although, Artisan-Api has production decetor itself, it is possible to install it globally.

### Endpoints

[](#endpoints)

As its name explains, all commands are available via HTTP with *POST* method. All commands will be generated as routes and integrated into Laravel Routing system. You only need to send a POST request and follow the signature, like other REST API endpoints.

There are two kinds of commands; one is normal commands like `php artisan list` or `php artisan cache:clear`, and the second form is `GeneratorCommands` which tend to create files within your application like `make:model` and `make:migration`. These kind of commands have different purposes, you should follow diffenerent convention.

> **`GeneratorCommand`** are instance of **`Illuminate\Console\GeneratorCommand`** that extends **`Illuminate\Console\Command`** class.

All commands existed by default or created by you will be discovered automatically and you do not have to do anything manually. Thus, their endpoints will be generated dynamically to your application. So if you delete/add any command class, there is no reason to worry.

#### Routes

[](#routes)

Let's dive into using endpoints:

Routes are generated with the following format:

```
https://domain.com/artisan/api/{command}/{subcommand}?args=key1:value1,key2:value2&options=opt1:value1,opt2
```

So the above endpoint will be translated to:

```
php artisan command:subcommand value1 value2 --opt1=value1 --opt2
```

And for **Generator** commands the endpoint is:

```
https://domain.com/artisan/api/{command}/{subcommand}/{name}?args=key1:value1,key2:value2&options=opt1:value1,opt2
```

**Pay attention that there is a `name` variable. As all Generator commands need an argument called `name`, this needs to be specified by what you desire.**

Command Examples:

```
php artisan list
```

will be translated to:

```
https://domain.com/artisan/api/list
```

and this:

```
php artisan cache:forget myCachedKeyName
```

will be translated to:

```
https://domain.com/artisan/api/cache/forget?args=key:myCachedKeyName
```

Another one:

```
php artisan optimize:clear -v
```

will be translated to:

```
https://domain.com/artisan/api/optimize/clear?options=v
```

A **Generator** one:

```
php artisan make:model MyModel --controller -f
```

will be translated to:

```
https://domain.com/artisan/api/make/model/MyModel?options=controller,f
```

> Options with more than *one* character will be translated to `--option`.

#### Responses

[](#responses)

After calling an endpoint, you will receive a `` response.

##### Successful

[](#successful)

When everything works perfectly: `status : 200 OK`

```
{
  "ok": true,
  "status": 200,
  "output": "Output of the command, given by Artisan"
}
```

##### Not found

[](#not-found)

When inputed command is not found by application: `status : 404 Not Found`

```
{
  "ok": false,
  "status": 404,
  "output": "Command 'command:subcommand' is not defined."
}
```

##### Invalid Arguments format

[](#invalid-arguments-format)

When arguments are given by an invalid format: `status : 500 Server Error`

```
{
  "ok": false,
  "status": 500,
  "output": "Argument(s) 'key:value' given by an invalid format."
}
```

##### Invalid Options format:

[](#invalid-options-format)

When options are given by an invalid format: `status : 500 Server Error`

```
{
  "ok": false,
  "status": 500,
  "output": "Options(s) 'key:value' given by an invalid format."
}
```

#### Forbidden routes

[](#forbidden-routes)

You might want to limit access to some critical commands like `db:seed`. **Artisan-Api** has thought about it and make those commands inaccessible by client. To specify forbidden commands, you are encouraged to add them within `config/artisan.php` file:

```
return [
    ...,

    'forbidden-routes' => [
        'clear-compiled',
        'tinker',
        'up',
        'down',
        'serve',
        'completion',
        '_complete',
        'db*', // all `db:seed` and `db:wipe` will be inaccessible
        '*publish' // like `vendor:publish`
    ]
];
```

Whenever client wants to access these commands by endpoints, it will be given a `404 NOT_FOUND` HTTP response.

#### Authentication

[](#authentication)

All enpoints will be generated under the `api` middleware of Laravel and prevented by built-in authentication system, mostly with `Sanctum` and API tokens.

### Configurations

[](#configurations)

As mentioned before, there is a configuration `config/artisan.php` file. You are free to modify specified values as you desire.

#### API Prefix and HTTP Method

[](#api-prefix-and-http-method)

Here, it is possible to change default API prefix and customize it as necessary. In addition you can access endpoints with any HTTP method as you set.

```
return [
    ...
    'api' => [
        'prefix' => "/artisan/api",
        'method'    => 'POST', // or ['POST', 'PUT']
    ],
    ...
];
```

#### Auto Run

[](#auto-run)

For some reason and mostly on production mode, you do not want to allow commands to be executed by HTTP request. To prevent this behavior, set that `auto-run` to `false`:

```
return [
    ...
    'auto-run' => false,
    ...
];
```

**This prevents not to load package's service-provider (`ArtisanApiServiceProvider`) by default.**

### Security

[](#security)

Artisan-Api has done its best to protect RCE vulnerability and other possible logical bugs.

> Artisan-Api uses `Symfony/console` under the hood and all commands execution are filtered and recognized by it. There is no direct call to `shell_exec()` or `exec()` functions.

#### IP restriction

[](#ip-restriction)

You can simply allow as many IP as you want to access to your commands. `'*'` means all IPs are trusted.

#### Middlewares

[](#middlewares)

There are two middlewares in **Artisan-Api**.

`CheckEnvMode` middleware exists to abort requests while in production environment.

`AbortForbiddenRoute` middleware exists to throw `404 NOT_FOUND` status code while accessing to forbidden routes.

### Useful tips

[](#useful-tips)

;)

### Todo

[](#todo)

1. It'd better be done to take `args` and `options` in query string, to be array.
    - Like: `?arg[key1]=value1&arg[key2]=value2` (it is a more standard way to deal with query string values)
2. Implement a way to deal with interactive commands like `tinker` (maybe can be implemented by socket)
3. Make response more readable for users, (remove "\\n", ...)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~28 days

Total

2

Last Release

1364d ago

PHP version history (2 changes)v1.1.1-betaPHP ^8.0

v1.2.1-betaPHP ^8.0.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/57cf970dcdfbb5aa22ad804e9a424affa1c78f4a1f025d7202e0cd247dc9798c?d=identicon)[arfar-x](/maintainers/arfar-x)

---

Top Contributors

[![arfar-x](https://avatars.githubusercontent.com/u/39987472?v=4)](https://github.com/arfar-x "arfar-x (27 commits)")

---

Tags

httpphpapiconsolelaravelrestartisancommand

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aariow-artisan-api/health.svg)

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

###  Alternatives

[nunomaduro/laravel-console-menu

Laravel Console Menu is an output method for your Laravel/Laravel Zero commands.

815412.0k48](/packages/nunomaduro-laravel-console-menu)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)[laragear/api-manager

Manage multiple REST servers to make requests in few lines and fluently.

161.8k](/packages/laragear-api-manager)

PHPackages © 2026

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