Project

General

Profile

Actions

Local dataportal development and test environment on Debian based Linux

DEPRECATED!!!! please see https://github.com/cybertaxonomy/cdm-dataportal/blob/develop/DEVELOPER.md


Install PHP packages

sudo apt-get install php libapache2-mod-php php-cli php-common php-curl php-gd php-mcrypt php-mysql php-xdebug php-json php-xml php-mbstring

copy edit.test.conf to /etc/apache2/sites-available/

open /etc/apache2/sites-available/edit.test.conf and replace all {USER_NAME} with your home folder resp. the output of echo $USER

add the following line to /etc/hosts

127.0.0.1   edit.test

create the workspace folder

mkdir ~/workspaces/
mkdir ~/workspaces/www/

enable the test vhost:

sudo chown root:root /etc/apache2/sites-available/edit.test.conf
sudo a2enmod rewrite
sudo a2ensite edit.test.conf
sudo systemctl restart apache2.service  

Check if php is working:

Copy info.php in the http root (e.g. ~/workspaces/www/) and open http://edit.test/info.php in your browser

Install Drush

http://docs.drush.org/en/8.x/install/

Local data portal installation

create the cdm_dataportal workspace:

mkdir ~/workspaces/cdm
cd ~/workspaces/cdm

now follow the instructions at https://github.com/cybertaxonomy/cdm-dataportal and use the Update - method 1

now you should have the folder ~/workspaces/cdm/drupal-7-cdm-dataportal

Switch to the develop branch

git checkout develop

Create a site

Each new site must be added to the ~/workspaces/www/drupal-7.x-dev/sites/sites.php. We recommend using the following php code to generate the correct site information in the sites.php:


$portal_names = array('my-first-site', 'my-second-site', 'new-site');

$portal_site_prefixes = array(
    'edit.test.d7'
);

$sites = array();

foreach ($portal_site_prefixes as $prefix) {
  foreach ($portal_names as $name) {
    $sites[$prefix . '.' . $name] = $name;
  }
}

The drupal sites will be available at http://edit.test/d7/{site_name}/. A per site configuration in apache is not needed since the virtual host configuration file edit.test.conf contains a AliasMatch directive which will make all drupal sites available under http://edit.test/d7/:

AliasMatch ^/d7/([^/]+)(.*)     /home/your-user-name/workspaces/www/drupal-7-cdm-dataportal$2

In order to test your site.php copy the sites-debug.php into the sites folder and execute it with php:

php sites/sites-debug.php`

clone an existing site site from a server

copy the according site folder to ~/workspaces/www/drupal-7.x-dev/sites/new_site

restore a dump of the according mysql database

edit ~/workspaces/www/drupal-7.x-dev/sites/sites.php to add your site

fix potential problems (drupal-fix-missing-modules.sh is available in server-scripts/drupal/drupal-fix-missing-modules.sh) https://dev.e-taxonomy.eu/old/trac/browser/trunk/server-scripts/drupal/drupal-fix-missing-modules.sh,
see also Migrating Data Portal sites between servers (clone site folder, settings and data base)

drupal-fix-missing-modules.sh http://edit.test/d7/new_site/

for trouble shooting (drupal_site_debug.php has been installed above!)

cd ~/workspaces/www/drupal-7.x-dev/
drush -l ${site-ulr} scr ~/drupal_site_debug.php

create a brand new site

in this example the new site is named "new_site"

mkdir ~/workspaces/www/drupal-7.x-dev/sites/new_site 
cd ~/workspaces/www/drupal-7.x-dev/sites/new_site 
ln -s ~/workspaces/cdm/cdm-dataportal/themes
mkdir modules
cd modules
ln -s ~/workspaces/cdm/cdm-dataportal/modules/cdm_dataportal

for further steps on setting up a site please refer to https://wiki.bgbm.org/bdinotes/index.php/EDITProductionNewDataPortal#Setup_and_install_the_new_site

====== from here on the documentation is not yet up to date ======

  1. Create database as root:

new_site

if you're not logged in to mysql as root then also:

 GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON new_site.* TO 'username'@'localhost';
  1. got to localhost/drupal/install.php

NOTE: If you are having problems with the graphical installer ("page not found" after installation) you may consider editing /var/www/drupal7-cdm_dataportal/sites/default/settings.php with the following and repeat all the steps above

 $databases = array();
 $databases['default']['default'] = array(
     'driver' => 'mysql',
     'database' => 'new_site',
     'username' => 'user',
     'password' => 'pass',
     'host' => 'localhost',
     'prefix' => '',
  );

NOTE: If you see this message "Multibyte string input conversion in PHP is active and must be disabled" then add the following to your mbstring.ini or php.ini file

mbstring.http_input = pass ;
mbstring.http_output = pass ;

Starting local CDM server from workspace

Requirements:

  1. In your run configurations you will find two Jetty Webapp launch configs ("cdmlib-remote-webapp - run" and "cdmlib-remote-webapp - profile")
  • "cdmlib-remote-webapp - run" will start the local CDM server
  • if you don't have anything configured yet the following output explains how to configure the CDM data bases for the CDM server
2014-04-15 13:41:08,244 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - property {cdm.datasource} not found.
2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - --> This property can be set in two ways:
2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - -->       1. as attribute to the ServletContext
2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - -->       2. as system property e.g. -Dcdm.datasource
2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - -->       3. in ~/.cdmLibrary/cdmlib-remote.properties
2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - Stopping application ...
  1. For the second option add a data source bean to your /home/user/.cdmLibrary/datasources.xml (<- create file if it does not exist) as follows (do NOT confuse with @/home/user/cdmLibrary/writableResources/cdm.datasources.xml@):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">

<bean id="cdmDB"  lazy-init="true" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="com.mysql.jdbc.Driver"/>
        <property name="user" value="user"/>
        <property name="password" value="password"/>
        <property name="jdbcUrl" value="jdbc:mysql://localhost/cdmDB?autoReconnect=true&amp;autoReconnectForPools=true&amp;"/>
    </bean>

</beans>
  1. In your "cdmlib-remote-webapp - run" launch configuration add to VM arguments:
-Dcdm.datasource=cdmDB
  1. To connect the data portal to your local CDM server add the following to Home -> Administration -> Configuration -> CDM Dataportal and choose your classification
http://localhost:8080/

Xdebug

install Xdebug:

pecl install xdebug

at the end of the install log, pecl shows something like:

Build process completed successfully
Installing '/usr/lib/php/20151012/xdebug.so'
install ok: channel://pecl.php.net/xdebug-2.6.0
configuration option "php_ini" is not set to php.ini location
You should add "zend_extension=/usr/lib/php/20151012/xdebug.so" to php.ini

If installation failed, try to install php7.4-dev first:

sudo apt install php7.4-dev

add xdebug to the php.ini: /etc/php/7.0/apache2/php.ini Use the xdebug.so location from the pecl output.

zend_extension=/usr/lib/php/20151012/xdebug.so
xdebug.idekey=PHPSTORM
xdebug.remote_enable=1
xdebug.remote_port=9008
service apache2 reload

Setup of PhpStorm

Workspace setup

Create a Drupal project in phpStorm for the cdm_dataportal project folder:

The final Directory settings for the project should now look like:

in the project view it looks like

Add Drupal code base to External libraries

open the external libraries configuration:

Setup the paths (this screenshot is only an example):

PhpStorm configuration to use Xdebug

Add a remote debug configuration to the localhost

This is the server configuration. Do not configure pathmappings for localhost!

If you are having problems configuring your debugger, you can use the Web Server Debug Validation tool to solve common problems with your debug configuration. The tool can be started by selecting the Run | Web Server Debug Validation option from the menu.

install the Firefox extension Xdebug helper

make sure the extension is configured to use the api-key PHPSTORM:

Project setup

deployment_connection

deployment_mappingpng

Setup for developing and running PHPUnit tests

see https://github.com/cybertaxonomy/cdm-dataportal/tree/master/modules/cdm_dataportal/test/phpUnit

Updated by Katja Luther over 1 year ago · 91 revisions