All Projects → PhiloNL → artisan-remote

PhiloNL / artisan-remote

Licence: MIT license
Artisan Remote is a package for Laravel to interact with your Artisan Commands via an HTTP API.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to artisan-remote

artisan-shortcuts
🍰 Register shortcuts to execute multiple artisan commands
Stars: ✭ 56 (-18.84%)
Mutual labels:  laravel-package, artisan
Blade Migrations Laravel
An intelligent alternative version of Laravel 5/6 Database Migrations - uses raw-sql syntax, transactions, auto-rollback, UP-DOWN-UP testing
Stars: ✭ 25 (-63.77%)
Mutual labels:  laravel-package, artisan
artisan-cloudflare
Laravel artisan commands for CloudFlare
Stars: ✭ 67 (-2.9%)
Mutual labels:  laravel-package, artisan
Laravel Opcache
Laravel Package for OPcache
Stars: ✭ 1,116 (+1517.39%)
Mutual labels:  laravel-package, artisan
Generator
Laravel 5.3+ Scaffold Generator, Support both bootstrap and Semantic UI
Stars: ✭ 327 (+373.91%)
Mutual labels:  laravel-package, artisan
laravel-migrate-check
An artisan command to check for pending migrations with proper exit code
Stars: ✭ 53 (-23.19%)
Mutual labels:  laravel-package, artisan
world
A Laravel package which provides a list of the countries, states, cities, currencies, timezones and languages.
Stars: ✭ 479 (+594.2%)
Mutual labels:  laravel-package
data-import
Laravel Enso XLSX Data Import package, built around the box/spout library, with templating, easy validation and more, for painless imports
Stars: ✭ 19 (-72.46%)
Mutual labels:  laravel-package
gitup
Laravel package to upload git commits to server(s) via (s)ftp.
Stars: ✭ 20 (-71.01%)
Mutual labels:  laravel-package
apposite
Conditionally apply Laravel validation rules, even when you don't have access to the validator instance.
Stars: ✭ 36 (-47.83%)
Mutual labels:  laravel-package
laravel-getid3
A Laravel package to extract metadata from media files. mp3, aac, etc. It can be used with files stored on different disks such as local disk, S3 etc.
Stars: ✭ 50 (-27.54%)
Mutual labels:  laravel-package
atlassian-connect-core
[Laravel 5.5+] The easiest way to create an add-on for the JIRA and Confluence
Stars: ✭ 42 (-39.13%)
Mutual labels:  laravel-package
laravel-print-api
Laravel package to access our print-api
Stars: ✭ 16 (-76.81%)
Mutual labels:  laravel-package
laravel-filterable
Laravel 5/6/7 package to handle filtering by query-string
Stars: ✭ 117 (+69.57%)
Mutual labels:  laravel-package
laravel-profane
Profanity Validator for Laravel
Stars: ✭ 79 (+14.49%)
Mutual labels:  laravel-package
swaggervel
Swagger for Laravel
Stars: ✭ 70 (+1.45%)
Mutual labels:  laravel-package
nova-qrcode-field
A Laravel Nova field to generate QR Code
Stars: ✭ 28 (-59.42%)
Mutual labels:  laravel-package
laravel-sybase
Connection and Laravel Eloquent driver for Sybase
Stars: ✭ 29 (-57.97%)
Mutual labels:  laravel-package
sweetalert
Laravel 5 Package for SweetAlert2. Use this package to easily show sweetalert2 prompts in your laravel app.
Stars: ✭ 28 (-59.42%)
Mutual labels:  laravel-package
Laravel-Auto-Hard-Deleter
Laravel and Lumen Auto Hard Deleter
Stars: ✭ 34 (-50.72%)
Mutual labels:  laravel-package

Build Status Total Downloads Latest Stable Version License

About Artisan Remote

Artisan Remote is a package for Laravel to interact with your Artisan Commands via an HTTP API.

Artisan Remote Desktop

If you want an easy way to interact with your Artisan commands via the UI, be sure to download the desktop app, which integrates with the Artisan Remote API.

  • Execute commands with just a click.
  • Provider command parameters via simple input fields.
  • Track output of previously executed commands.
  • Supports unlimited Laravel application.
  • Your application environment details in one single overview.
  • Works on Mac, Windows and Linux.

Download for Mac, Windows or Linux distribution via Unlock.

Installation

To get started, require the package via Composer:

composer require philo/artisan-remote

API endpoints

The environment endpoint will return information about your application environment, like your PHP and Laravel version.

GET /artisan-remote/environment

Content-Type: application/json
Accept: application/json
Authorization: Bearer 039ede05-d2c1-4ab4-8869-945e805e6bbc

{
  "applicationName": "Unlock.sh",
  "phpVersion": "7.4.12",
  "frameworkVersion": "7.28.1",
  "environment": "production",
  "inMaintenanceMode": true,
  "maxExecutionTime": "30"
}

Get a list of the available commands. You can define the commands you want to make available in the artisan-remote.php config file.

GET /artisan-remote/commands

Content-Type: application/json
Accept: application/json
Authorization: Bearer 039ede05-d2c1-4ab4-8869-945e805e6bbc

[
  {
    "name": "down",
    "description": "Put the application into maintenance mode",
    "arguments": [],
    "options": [
      {
        "name": "message",
        "description": "The message for the maintenance mode",
        "default": null,
        "isArray": false,
        "isRequired": false,
        "isOptional": true
      },
      {
        "name": "retry",
        "description": "The number of seconds after which the request may be retried",
        "default": null,
        "isArray": false,
        "isRequired": false,
        "isOptional": true
      },
      {
        "name": "allow",
        "description": "IP or networks allowed to access the application while in maintenance mode",
        "default": [],
        "isArray": true,
        "isRequired": false,
        "isOptional": true
      }
    ]
  },
  {
    "name": "up",
    "description": "Bring the application out of maintenance mode",
    "arguments": [],
    "options": []
  }
]

And finally, you can use the invoke endpoint to execute your command.

POST /artisan-remote/commands/invoke

Content-Type: application/json
Accept: application/json
Authorization: Bearer 039ede05-d2c1-4ab4-8869-945e805e6bbc

{
  "name": "down",
  "options": {
    "message": "We will be back in 15 minutes",
    "retry": "900",
    "allow": [
      "127.0.0.1"
    ]
  }
}

// Response
{
  "rawCommandOutput": "\u001b[33mApplication is now in maintenance mode.\u001b[39m\n",
  "HtmlCommandOutput": "<span style=\"background-color: transparent; color: #e5e510\">Application is now in maintenance mode.<\/span><span style=\"background-color: transparent; color: #e5e5e5\">\n<\/span>",
  "exitCode": 0,
  "executionTime": 0.017518997192382812
}

API authorization

Before you can make requests to the API endpoints, you need to set up authorization. You can authorize access to specific commands in the artisan-remote.php config file. For example, you might want to allow your client to run the artisan up and down commands.

<?php

return [
    'commands'     => [
        \Illuminate\Foundation\Console\UpCommand::class,
        \Illuminate\Foundation\Console\DownCommand::class,
        \Illuminate\Cache\Console\ClearCommand::class,
    ],
    'auth'         => [
        // This API token will be able to access only the up and down command.
        '79e9ab08-bdc0-4bef-8af2-5e5b5579f9af' => [
            \Illuminate\Foundation\Console\UpCommand::class,
            \Illuminate\Foundation\Console\DownCommand::class,
        ],
        // This API token will be able to access the up, down and cache:clear command.
        '3c562cb3-62ba-4fe4-9875-528ecae6e8b4' => ['*'],
    ],
    'route_prefix' => 'artisan-remote',
];

It's best practice not to include any credentials directly in your configuration file, so make sure to use environment variables in production.

// artisan-remote.php
'auth'         => [
    env('CLIENT_ARTISAN_REMOTE_API_KEY') => [
        \Illuminate\Foundation\Console\UpCommand::class,
        \Illuminate\Foundation\Console\DownCommand::class,
    ],
]

// .env
CLIENT_ARTISAN_REMOTE_API_KEY=79e9ab08-bdc0-4bef-8af2-5e5b5579f9af
Running commands when your application is in maintenance mode

By default, you will not be able to execute commands when your application is in maintenance. To run commands while your application is in maintenance mode, you will need to adjust the CheckForMaintenanceMode middleware.

// app/Http/Middleware/CheckForMaintenanceMode.php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;

class CheckForMaintenanceMode extends Middleware
{
    /**
     * The URIs that should be reachable while maintenance mode is enabled.
     *
     * @var array
     */
    protected $except = [
        'artisan-remote/*'
    ];
}

Credits

License

Artisan Remote is open-sourced software licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].