Site Administrator
  • Overview
  • Getting Started
    • Installation
    • Configuration
    • Access & Navigation
  • User Guide
    • Dashboard
    • Modules
      • Members
      • Page Editor
      • FAQs
      • News
      • Photo Gallery
      • Forms
      • Catalog
      • Events
      • Staff
    • Settings
  • Developer Guide
    • The Basics
      • Controllers
      • Rendering with Vue JS
      • Responses
      • Routing
      • Views
      • View Models
    • Models & Doctrine ORM
      • Models
      • Entity Manager
      • Repositories
    • Advanced Topics
      • Creating a Module
      • Creating a Theme
      • Events
      • Logging
      • modRequest
      • IOC & Dependency Injection
    • Utilities & Helpers
      • DateTime
      • Doctrine Utils
      • URL
    • Command Line
      • Doctrine CLI
      • Executing Controllers
    • Vue Components
  • Credits
  • Old Guide
    • Site Administrator
      • Site Administrator
Powered by GitBook
On this page
  1. Developer Guide
  2. Command Line

Executing Controllers

SA3's command line tool offers an interface into the controller methods of an application's modules. This allows developers to execute code through external scripts or direct CLI commands.

php app.php -c=executeController -e=environment -a={controller}@{method}

By Example

<?php
namespace sa\Members;
​
use \sa\application\controller;
​
class MembersExport extends controller {
    public function exportToCsv() {
        // <implementation code>
    }
}

The CLI command to execute exportToCsv method is

php app.php -c=executeController -e=environment -a=MembersExport@exportToCsv

Duplicate controller names?

The previous command will execute the exportToCsv method found in the MembersController controller. For simple applications, this will suffice, but what if there are two controllers named MembersController?

You can specify a namespace to distinguish one controller from another.

php app.php -c=executeController -e=environment -a=\sa\Members\MembersExport@exportToCsv
PreviousDoctrine CLINextVue Components

Last updated 7 years ago