EasyEngine/easyengine

ee4 site command refactor

Closed this issue · 2 comments

EasyEngine has been shifted to PHP so that it's majority users, i.e., WordPress users and developers can contribute to it. To make contribution easy, we were discussing on the commands architecture. The following two approaches have been thought of as of now:

EEv4 Commands Architecture

Hooks and Filters to extend functionalities of EEv4:

  • In this approach something like:
    ee site create example.com --type=[wp|laravel|php|html] can be passed.
  • Then with the help of hooks and filters attached the functions of site-command, people can build on creation of new site-types.
  • Downside: There are chances of overlapping and conflicts if user has installed commands having hooks for same site-types.

Make Site-Command Abstract:

  • By making Site-Command abstract, people can take the base of site-command and its common functions like list, enable, disable, delete, info etc.
  • They can then override the functions like create and write their logic of creation that is required for creation of that particular site-type.
  • The commands would look like:
    ee wp create example.com -> Having extended site-command and adding command wp in the package.
    ee laravel create example.com -> Having extended site-command and adding command laravel in the package.

Also, If we can/want to keep above both option:

We can map site type of "site" command with packages commands.
Like:
ee site create example.com --type=wp will run ee wp create example.com and we can have another command from a package like ee laravel create example.com which can also be triggerd by site command (ee site create example.com --type=laravel)
( FYI: wp-cli help command is used same way wp core --help will trigger/call wp help core)

And here we can provide an option to use default site type command:
Like: ee default set site_type=wp this command can be set for ee site command so that ee site create example.com can create default WordPress site every time when we don't need to pass site type. And user can change type using ee default set site_type=laravel as per needs.

Using this approach can be easy to maintain since by providing packaging system we already added option to create new command ( i.e, ee laravel ) so if we provide another option using hook for ee site create example.com --type=[wp|laravel|php|html] then there will be two type of site create will be supported which might cause more conflict. And another reason to do this way is because we already have support of adding command using packages.

Once this is finished, start EasyEngine/admin-tools-command#1