Cli Commands

The spoova framework uses a terminal command mi which is an helpful command to modify or update the developers' project app. This command can also be used for generating classes or files needed within the application. In this page, we will learn about some useful cli commands that can make the development of project applications easier.

Commands

A list of helpful cli mi commands are listed below with their descriptions


add
The "add" directive is being used to add a new file. List of files that can be added are:
  • windows
  • frames
  • routes
  • apis
  • models
  • rex (template file)

add:window
This command is used to create a window file into the window directory or subdirectory. If such path does not exist, the folder will automatically be generated as a subdirectory of the window directory. Path supplied can be in form of slashes or dots. When the path is not supplied, the file will be added directly into the window directory.
Syntax
  php mi add:window <dir?><windowName> <extends?> [-O?];
  
    where: 

        name => name of controller file
        path => optional path to contoller file
    
        
    Ex1: php mi add:window Info   //add class windows\Info. 
    Ex2: php mi add:window Info.User //add class windows\Info\User. 
    Ex3: php mi add:window Info.User UserFrame //add class windows\Info\User, extend to Frames\UserFrame.  
    Ex4: php mi add:window Info UserFrame -O //add class windows\Info, extend to Frames\UserFrame, overwrite any previous file.  
                
                

add:frame
This "frame" command is used to create a frame file into a "windows/frames" directory which is a subdirectory of the windows folder (directory).
Syntax
  php mi add:frame <path> [-O?]
  
    where: 

        path => path to frame file within Frames directory
        [-O] => overwrite old file (optional)
        
    Ex1: php mi add:frame Info   //add windows/Frames/Info.php. 
    Ex2: php mi add:frame Info.UserFrame //add windows/Frames/Info/UserFrame.php . 
    Ex3: php mi add:frame Info.UserFrame -O //add windows/Info/UserFrame.php  overwrite any previous file.  

  
                

add:route
This "route" command is used to create a route entry point file into a "windows/Routes" directory which is a subdirectory of the windows folder (directory).
Syntax
  php mi add:route <path> <extends?> [-O?]
  
    where: 

        path => path of route file within window/Routes directory
        extends => extend to frame file
        -O => Overwrite any existing file.
            
    Ex1: php mi add:route MyRoute   //add windows/Routes/MyRoute.php. 
    Ex2: php mi add:route Loc.MyRoute //add windows/Routes/Loc/MyRoute.php. 
    Ex3: php mi add:route Loc.MyRoute UserFrame //add windows/Routes/Loc/MyRoute.php extend to Frames\UserFrame.  
    Ex4: php mi add:route Loc.MyRoute UserFrame -O //add windows/Routes/Loc/MyRoute.php extend to Frames\UserFrame overwrite any previous file.  
  
                

add:api
The "api" command is used to create a routed api files into a "windows/API" directory which is a subdirectory of the windows folder (directory).
Syntax
  php mi add:api [name] [extends?] [\Dir?] [-O?]
  
    where: 

        name => name of api route
        extends? => extend to a frame class
        \Dir => directory of api route 
        -O   => overwrite any previous file   
    
    Ex1: php mi add:api Info   //add windows/Routes/Info.php. 
    Ex2: php mi add:api Info \Loc //add windows/Routes/Info.php, add windows/Routes/Loc/InfoAPI.php. 
    Ex3: php mi add:api Info UserFrame //add windows/Routes/Info.php extend to Frames\UserFrame.  
    Ex4: php mi add:api Info UserFrame -O //add windows/Routes/Info.php extend to Frames\UserFrame overwrite any previous file.  
    Ex5: php mi add:api Info UserFrame \Loc -O //add windows/Routes/Info.php extend to Frames\UserFrame, add windows/Routes/Loc/InfoAPI.php, overwrite any previous file.  

  
                

add:migrator
This command is used to add a migration file. Migratrion files are added based on specific naming syntaxes. Migration files that starts with the identifier name "create_" are assumed to be for creating tables while those with starting "alter_" are assumed to be for altering tables. All migration files are generated and added directly to the migrations/ directory. The migration file name is also used as the class name. This means that only names accepted for naming classes should be used.
Syntax
  php mi add:migrator name
  
    where: 

        name => name of migration file  
  
                

add:model
This model command is used to create a model file into a models directory which is a subdirectory of the windows folder (directory).
Syntax
  php mi add:model <path> [-O?]
  
    where: 

      path => path to model file within the windows/Models directory.
      -O => overwrite any previous file.

    Ex1: php mi add:model UserModel            //add windows/Models/UserModel.php 
    Ex2: php mi add:model Access.UserModel     //add windows/Models/Access/UserModel.php 
    Ex3: php mi add:model Access.UserModel -O  //add windows/Models/Access/UserModel.php, overwrite previous file 

  
                

add:rex
This command is used to create a template rex file into the windows/Rex directory. Path supplied can be in form of dots or slashes. When adding the file name, only name should be added without any file extension. The type of rex file can be supplied using the column directive. However if no type is defined, then the rex file will assume a default extension of php.
Syntax
  php mi add:rex  <pathname>.<filename><:ext?>
  
    where: 

      filename => name of rex file
      pathname => optional path to contoller file
      :ext     => options [:css|:js|:php]


    Ex1: php mi add:rex index            //add windows/Rex/index.rex.php 
    Ex2: php mi add:rex index:css        //add windows/Rex/index.rex.css 
    Ex3: php mi add:rex index:js         //add windows/Rex/index.rex.js 
    Ex4: php mi add:rex build.index:css  //add windows/Rex/build/index.rex.css 
  
                

backup project
This command is used to storage backups. It uses interactive console steps to determine how best to generate project backups. The default backup folder name is "backup".
Syntax
  php mi backup project
                

backup :clear
This command is used to delete the entire project backups from the backup/ directory that is reserved for backups. It is essential to trend carefully when applying this command since all the backups removed cannot be recovered.
Syntax
  php mi backup :clear
                

clean storage
This command is used to clean storage files. When executed, this will remove all storage files from the storage path.
Syntax
  php mi clean storage
                

config:all
This is an interactive console guide to set up all required essential configuration parameters.
Syntax
  php mi config:all

  Note: database connection parameters must always be wrapped within quotes.
                

config:dbonline
This configures the online database connection parameters. Online parameters are used when working on live environment.
Syntax
  php mi config:dbonline "dbname dbuser dbpass dbserver dbport dbsocket"
  
    where: 

        dbname => database name
        dbuser => database username
        dbpass => database password 
        dbserver => database server
        dbport => database port 
        dbsocket => database socket

        NOTE: Empty values are replaced with dash (i.e "-")

        Ex: php mi config:dbonline "tester root - localhost 3306"   //set online database connection parameters 
  
                

config:dboffline
Similarly to dbonline, the dboffline is used to configures the online database connection parameters. The offline connection parameters are also triggered to be used to connect to database locally.
Syntax
  php mi config:dboffline "dbname dbuser dbpass dbserver dbport dbsocket"
  
    where: 

        dbname => database name
        dbuser => database username
        dbpass => database password 
        dbserver => database server
        dbport => database port 
        dbsocket => database socket

        NOTE: Empty values are replaced with dash (i.e "-")

        Ex: php mi config:dboffline "tester root - localhost 3306"   //set offline database connection parameters 

                
Example
  php mi config:dboffline "mydatabase root - localhost 3307 -"
  
    where: 

      mydatabase => database name
      root       => database username
      -          => database password (empty) 
      localhost  => database server
      3307       => database port 
      -          => socket (empty)
  
                

config:env
This configures the icore/.env environment keys.
Syntax
  php mi config:env key value
  
    where: 

      key   : key to be configured

      value : value of key

      Ex: php mi config:env API_KEY some_value
  
                

config:usersTable
This configures the users table name in a given database. This table is expected to contain the user information such as user id or unique id field that can be used to trace a user.
Syntax
  php mi config:usersTable tablename
  
    where: 

      tablename => name of database table

      Ex: php mi config:userTable users  //set database user info table
  
                

config:cookieField
In most login-logout system, users tend to keep records such as "rememberMe" which enables users to be able to login without difficulty. The cookie field can be used to store a cookie token than can be retrieved for logging in. Although it is not a neccesity to have a cookie field in the database user's table, yet, it is important to have a structure in place that supports this. Hence spoova suggests that for every project application, a cookie field should exist in the selected database user's table. The name of this cookie field should be supplied for use when logging in or out of an application.
Syntax
  php mi config:cookieField tablename
  
    where: 

      tablename => name of database table

      Ex: php mi config:cookieField cookie   //set cookie column in user info table 
  
                

config:idField
Every login-logout system, requires that a user should have an identification number or string. Spoova naturally do not assume the user id column (or field) name is usually an integer field or usually named "id". Instead, a name must be supplied which helps spoova to locate the user id column from the user table already set. The id field used may be a unique field (e.g email, id, phone. e.t.c)
Syntax
  php mi config:idField column
  
    where: 

      column => name id column

      Ex: php mi config:idField email  //set user id column name in user table
  
                

config:meta
If meta tags are configured by default to be loaded by the resource class automatically, when importing static files using any of the resource importer function, method or directives (e.g <?= Res::import() >, Res()), the resource class will build meta tags using the configuration set in icore/filemeta.php file and the predefined meta tags will be added only once to the webpage.
Syntax
  php mi config:meta [on|off]
  
    where: 

      on  => switches automatic importation on 
      off => switches automatic importation off

      Ex: php mi config:meta on  //set meta tags autoloading from icore/filemeta.php configuration on 
  
                

cli

The cli directive shows a list of available cli commands. When the -lists directive is applied, more details of cli commands are displayed.
Syntax
  php mi cli [-lists]
  
    where: 

      -list  => optional directive to display more information on cli commands

      Ex: php mi cli -lists 
  
                

features
This command shows a list of spoova features
Syntax
  php mi features
  
    where: 

      features  => shows a list of available features
  
                

info
The info command is used to show a description of a particular command.
Syntax
  php mi info <command>
  
    where: 

      command  => cli command name (e.g add:window)

      Ex1: php mi info add:window  //displays description for "add:window" command
      Ex2: php mi info add:routes  //displays description for "add:routes" command
      Ex3: php mi info "watch status"  //displays description for "watch status" command
  
       You can view a list of available commands using php mi cli -lists
               

Install
This command installs the entire spoova application by testing all configuration parameters supplied for database and the entire application. It also creates neccessary database if the selected database name does not exist as long as the database connection parameters have been properly set. When no option is supplied, then the entire application is installed. Specific options performs their relative functions as shown below.
Syntax
  php mi install [db|dbname] [folder?]
  
    where: 

      db     => test the database connection parameters defined in "icore/dbconfig.php" file 
      dbname => creates default database name supplied in "icore/dbconfig.php" file using the defined connection parameters
      folder => refers to an optional custom folder name in project root that contains an "icore/dbconfig.php" file with connection parameters.
  
                


Migrate
The "migrate" command is used to step up, step down or get migration status.
Syntax
  php mi migrate [up|down|status]
  
    where: 

      up     => step up the migration files
      down   => step down the migration files
      status => fetches the migration status table.
  
                
Note that when running migrations down, the number of times to run migrations down can be specified. This is done by supplying the number of down migrations after the "migrate down" command. For example, mi migrate down 4 will step down the migration files in four times. This means that only the last 4 recent migration files will be affected while others will be ignored.

project
This command is used to create a new separate project application. This should be done from the spoova project pack directory. When a new project file is created using the cli, all essential mapping of file to the current enviroment is done. It is highly suggested to create a new project app using the cli which ensures that the new project app is essentially ready for configuration.
Syntax
  php mi project <project_name>
  
    where: 

      project_name => name of new project application

      Ex: php mi project lumen  //create separate project name "lumen"
  
                  

support
This command displays the current support of spoova frame in terms of php version, mysql server, web servers and other essential informations.
Syntax
  php mi support
                

version
This command displays the current version of spoova frame
Syntax
  php mi version
                

watch
Watch is the inbuilt spoova live server system. This system can be switched to online or offline or disabled mode.
Syntax
  php mi watch [online|offline|disabled|status]
  
    where: 

      online    => sets watch for both offline and online environments
      offline   => sets watch for offline environment only
      disabled  => disables the watch entirely for both environments
      status    => get the current configuration status of watch

      Ex1: php mi watch online    //set watch to online and offline environments 
      Ex2: php mi watch offline   //set watch to offline environment 
      Ex3: php mi watch disabled  //set watch to disabled mode 
      Ex4: php mi watch status    //get current watch status.
  
                

wiz
This command starts a wizard that is capable of running php codes in the command line in the offline environment. The wiz also allows pasting of code lines on the command line. In order to execute commands, developer must end code with a newline followed by semicolon delimiter and then an enter. This tells the wiz to run or process the code. If the delimiter is not added on a separate line, the wiz will just assume that the delimiter is part of the code and will not execute it.
Syntax
  php mi :wiz
                  
When working with wiz, all important namespaces must be fully defined in a way that it becomes accessible.