Remote Access Client
Apex contains built-in support for remote access, allowing a system to be remotely updated instantly from another Apex installation without requiring access to the
server. This is useful for designers / developers who are working on a remote Apex installation, but have a desire to easily upload modified files to the system from their own
local Apex installation. This guide explains how to setup remote access, and the
various CLI commands available.
Within this guide the remote server is the Apex installation that will be automatically updated, and the local server will be the Apex installation
the designer / developer is modifying, and wishes to upload to the remote server from.
- Setup Remote Access
- CLI Commands
Setup Remote Access
By default remote access is disabled, but you may easily enable it. Login to the administration panel
of the remote server, visit the Settings->General menu, and top of the API Keys tab you will see a section for remote access. Change the radio button to enable it, and update the settings. Then also
hit the button to regenerate the API key. Please ensure to copy and save this API key, as you will only be able to read it once.
Next, within the local server open terminal, change to the Apex installation directory, and run the command:
./apex update_remote_apikey. This will prompt you for the
full installation URL of the remote server (eg. https://example.com), and the API key. Enter both, and that's it! Remote access is now enabled, and ready to go.
All remote access functionality is available via CLI commands from the local server, which are explained below. Please note, depending on
server permissions, all updates to the remote server may take a couple minutes as they will have to wait for the next crontab job to run again.
remote_copy [FILE1] [FILE2] [FILE3]...
Description: Copies files from the local server to the remote server, and can optionally accept multiple filenames delimited by a space. The filenames must be relative to the Apex installation directory.
apex remote_copy src/mypackage/somelib.php
apex remote_copy views/admin/some_menu/myview.tpl views/tpl/public/home_page.tpl
remote_rm [FILE1] [FILE2] [FILE3] ...
Description: Deletes files / directories from the remote server, and can contain multiple files delimited by a space. All filenames must be relative to the installation directory.
apex remote_rm src/mypackage/somelib.php
apex remote_rm views/admin/some_menu/myview.tpl views/tpl/public/home_page.tpl
remote_save TYPE PACKAGE:[PARENT:]ALIAS
Description: Saves a component to the remote server, regardless if it's being created for the first time or only the code files are saved. This is similar to the standard
apex create CLI command to create a component, except if the component already exists all code files associated with it will be saved on the remote server.
apex remote_save view admin/settings/mypackage
apex remote_save table mypackage:some_table
remote_delete TYPE PACKAGE:[PARENT:]ALIAS
Description: Deletes a component from the remote server, including all code files associated with it.
apex remote_delete view admin/settings/mypackage
apex remote_delete table mypackage:some_table
Description: Executes the given SQL statement against the remote database. If it's a SELECT statement, returns the results in JSON format.
apex remote_sql SELECT username,email FROM users ORDER BY id
apex remote_sql INSERT INTO mypackage_test (amount, name) VALUES (15, 'Test Product')
Description: An alias of the
apex scan CLI command, except this scans a package on the remote server. This will also save the current contents of the /etc/PACKAGE_ALIAS/package.php file, and save it accordingly to the remote server.
apex remote_scan mypackage