Allows limitless communication between Drupal (6 and 7) sites.

Code Server provides a framework for calling PHP functions on a Drupal site from code running on a different Drupal site.

Status for Drupal 8 and 9:

I intend to produce a D8/9 versions of CodeServer when I'm involved in a project that needs them. In the meantime, if anyone interested in producing D8/9 versions, please contact me. As an alternative solution, consider the JSON-RPC module.

Background

Some background as to why this module was created here.

Applications include:

  • Synchronising data (content, users, configuration, etc.) between two or more sites.
  • Regression testing.
  • Data migration.
  • More!

See the live demonstration page for some technical details. That page is generated by the codeserver_test module which is included in the project package.

Example 1 - content synchronisation:

  // Set the node id of the node we are going to copy.
  $nid = 1234;
  // Instantiate CodeServer using the configuration named 'my_remote_site'.
  $remote = new CodeServer('my_remote_site');
  // Load a node from the remote site.
  $node = $remote->node_load($nid);
  // Save the node on the local site.
  node_save($node);

That's an over-simplified example, but would work fine if both sites had compatible content-types, users, taxonomy, etc. as would very often be the case for development and production versions of the same site. You could load a node from a D6 site and save it on a D7 site, but of course you would need to do some additional processing.

Example 2 - regression testing:

  // Instantiate CodeServer using the configuration named 'version1_site'.
  $v1 = new CodeServer('version1_site');
  // Instantiate CodeServer using the configuration named 'version2_site'.
  $v2 = new CodeServer('version2_site');

  // Compare the results of version 2 of our software with version 1.
  if ($v2->important_calculation() !== $v1->important_calculation()) {
    drupal_set_message('Oops', 'error');
    panic();
  }

PHP 7.x support

I would expect it to work but have not yet tested CodeServer under PHP 7. If anybody else has, please provide feedback here: #3120003: Test PHP 7 compatibility

Drush integration:

Two drush commands are provided:

  • codeserver-call calls a PHP function on the remote site
  • codeserver-run runs PHP on the remote site. The code to be run can be specified on the command-line or read from a local file.

Run drush help csc csr to see help information and examples.

Security:

  • Communication between client and server is encrypted with strong encryption.
  • Access to services is limited to clients with the correct encryption key.
  • Access to services is limited to configured IP addresses (e.g: 127.0.0.1).
  • Access can be further limited by user id, password and specific permission.
  • Access to PHP functions is limited to configured function names.
  • Includes a safe_serialize option which completely avoids any PHP Object Injection risks that might otherwise exist, because PHP's unserialize() function is not used at all.

For additional security, it's best to you use HTTPS or set up a VPN or SSH tunnel to handle the client-server connection.

Target audience:

Developers. You should definitely not install this module if you don't have suitable PHP programming skills and sufficient knowledge of security topics.

Related modules:

CodeServer is not meant to compete with existing modules - it takes a unique approach to inter-site communication. In general, CodeServer is not appropriate for developing REST services. Here are some other modules that may fit your needs better:

Drupal versions:

Drupal 6 and 7 versions of Code Server are available. Drupal 8 and 9 versions are expected to be available at some point. Please contact me if you're interested in assisting with that.

Further information:

You can visit the demo page to get an introduction to this module. That page is generated by the codeserver_test module which is included in the project package.

Supporting organizations: 
Architecture, development.

Project information

Releases