AthenaeumAthenaeum
Packages
  • next
  • current
  • v9.x
  • v8.x
  • v7.x
  • v6.x
  • v5.x
  • v4.x
  • v3.x
  • v2.x
  • v1.x
Changelog
GitHub
Packages
  • next
  • current
  • v9.x
  • v8.x
  • v7.x
  • v6.x
  • v5.x
  • v4.x
  • v3.x
  • v2.x
  • v1.x
Changelog
GitHub
  • Version 4.x

    • Release Notes
    • Upgrade Guide
    • New to this...
    • Origin
  • Circuits

    • Circuits
    • How to install
    • Setup
    • Usage
    • Events
  • Config

    • Configuration Loader
    • How to install
    • Setup
    • Load Configuration Files
    • Custom File Parsers
  • Console

    • Command and Schedule Registration
    • How to install
    • Setup
    • Commands
    • Schedules
  • Container

    • IoC Service Container
    • How to install
    • registerAsApplication()
    • destroy()
  • Core

    • Athenaeum Core Application
    • Prerequisite
    • How to install
    • Integration
    • Usage

      • Configuration
      • Service Providers
      • Service Container
      • Events
      • Caching
      • Logging
      • Console
      • Task Scheduling
      • Exception Handling
      • Extending Core Application
      • Testing
  • Dto

    • Data Transfer Object (DTO)
    • How to install
    • Create Interface
    • Implement DTO
    • How to use
    • Populate
    • Export
    • Json
    • Serialization
    • Nested DTOs
    • Array DTO
  • Events

    • Register Listeners and Subscribers
    • How to install
    • Setup
    • Listeners
    • Subscribers
  • Http

    • Clients

      • Http Clients
      • How to install
      • Setup
      • Basic Usage
      • Available Methods

        • Fluent Api
        • Protocol Version
        • Base Uri
        • Http Method and Uri
        • Headers
        • Accept & Content-Type
        • Authentication
        • Http Query
        • Payload Format
        • Payload
        • Attachments
        • Cookies
        • Response Expectations
        • Conditions
        • Criteria
        • Redirects
        • Timeout
        • Driver Options
        • Driver
      • Http Query Builder

        • Introduction
        • Select
        • Where
        • Dates
        • Include
        • Pagination
        • Sorting
        • Raw Expressions
        • Custom Grammar
    • Cookies

      • Http Cookies
      • How to install
      • Usage
  • Properties

    • Properties Overload
    • How to install
    • Usage
    • Naming Convention
    • Properties Visibility
  • Service

    • Service Registrar
    • How to install
    • How to use
  • Support

    • Introduction
    • How to install
    • Laravel Aware-of Helpers

      • How to use
      • Enforce Via Interface
      • Custom Default
      • Pros and Cons
      • Available Helpers
    • Aware-of Properties

      • Generator
      • Available Aware-of Helpers
    • Live Templates
  • Testing

    • Introduction
    • How to install
    • Test Cases
    • Testing Aware-of Helpers
  • Utils

    • Introduction
    • How to install
    • Array
    • Json
    • Math
    • Method Helper
    • Populatable
    • Version
You are viewing documentation for an outdated version. It is no longer supported!

Console

Laravel's Console Application is used to enable command-line interfacing. It offers the ability to register and execute custom console commands.

Create Commands

To create a console command, extend the Command class.

<?php

namespace Acme\Console;

use \Illuminate\Console\Command;

class MyCommand extends Command
{
    protected $signature = 'test:my-command';

    protected $description = 'A simple test command';

    public function handle(): int
    {
        $this->output->text('Hi there...');

        return 0;
    }
}

For additional information about how to create console commands, please review Laravel's documentation.

Note

This package does not offer Laravel's make:command generator utility. If you wish to create console commands, then you have to do so manually.

Register Commands

You can register the command via the configs/commands.php configuration file. Please review the Console Package's documentation for details.

Via Service Provider

Should you require more advanced console command registration, e.g. conditional registration, then you can do so via a Service Provider. In the boot() method, you can invoked the commands() method to register your desired commands.

<?php

namespace Acme\Console\Providers;

use Illuminate\Support\ServiceProvider;

class MyConsoleServiceProvider extends ServiceProvider
{
    public function boot()
    {
        // ... your logic / condition check ...

        if($shouldRegisterCommands){
            $this->commands([
                \Acme\Console\MyCustomCommandA::class,
                \Acme\Console\MyCustomCommandB::class
            ]);
        }
    }
}

Once you have completed your service provider, register it in your /configs/app.php configuration file.

<?php

return [
    // ... previous not shown ...

    'providers' => [
        \Acme\Console\Providers\MyConsoleServiceProvider::class
    ],
];
Edit page
Last Updated: 08/09/2020, 18:52
Contributors: Alin Eugen Deac
Prev
Logging
Next
Task Scheduling