PHP Development


PHP development is done on a Windows 10 PC with XAMPP and MySQL installed. This section describes how to edit and debug PHP files.

  • Run the XAMPP Control Panel

    • Start Apache
    • Start MySQL
    • Close or hide the panel
  • Run PhpStorm

    • Open the Digital Archive project: C:\xampp\htdocs\omeka

How To:

  • Global search of files: shift-ctrl-f (press Esc to close the panel)
  • Run a site in debugging mode: Run > Debug 'Omeka'


Debugging a remote request

Remote requests are normally posted to a production instance of the Digital Archive. For development purposes, a logged-in super user can make GET requests in order to get into the debugger to set breakpoints. This technique is supported by the AvantAdmin::handleRemoteRequest() method for URLs like these:


The first request above is for a remote health check request.

The second request above is for a hybrid-add action, but the URL does not contain the data to be added. Because of the nature and length of the data, it's not practical to pass it as query string argument, but you can copy/paste the data you want to test with into the the $data variable in method HybridImport::getSourceRecordData().

Force style.css reload

  • Edit themes\AvantTheme\common\header.php
  • Bump $version passed to queue_css_file('style', 'all', false, 'css', $version);

Execute Elasticsearch query in Kibana

  • Open AvantElasticsearchQueryBuilder::constructSearchQuery in PhpStorm
  • Set a breakpoint on the last line of code return $params
  • Perform a search that triggers the breakpoint
  • Copy/paste the value of $kibana into the Kibana Dev Tools
  • Use Kibana's Auto Indent to format it

See the Kibana section on the AWS page.

See SQL queries and logging

To see queries emitted by AvantSearch

  • Open SearchQueryBuilder::buildAdvancedSearchQuery in PhpStorm
  • Set a breakpoint on the last line of code $sql = (string)$this->select;
  • Perform a search that triggers the breakpoint
  • Step past the assignment to $sql
  • Right click on $sql and choose Evaluate Expression
  • On the Evaluate dialog enter (string)$sql
  • Click the Evaluate button
  • In MySQL Workbench:
    • Choose File > New Query Tab
    • Paste the SQL into the empty query window
    • Click the Beautify/Reformat icon (looks like a wide paint brush)
    • Shift the text to the left so you can see it

To see queries emitted by Omeka

  • Open AvantSearchPlugin::hookItemsBrowseSql($args) in PhpStorm
  • See a breakpoint on the call to buildSearchQuery($args)
  • Perform a search that triggers the breakpoint
  • Right-click on $args and choose Evaluate Expression
  • In the Evaluate dialog type (string)$args["select"]
  • Click the Evaluate button
  • Follow the previous set of steps to view the SQL in MySQL Workbench

To log queries to errors.log

  • Edit C:\xampp\htdocs\omeka\application\config\config.ini
  • Set:
    • log.sql = true
    • log.priority = Zend_Log::DEBUG
  • View C:\xampp\htdocs\omeka-2.5\application\logs\errors.log in PhpStorm
  • If the file does not always refresh right away:
    • Click in in the errors.log PhpStorm window
    • Click in the browser window where you are debugging
    • Come back to PhpStorm where errors.log should have refreshed

To see queries as they occur:

  • Open C:\xampp\htdocs\omeka-2.6\application\libraries\Zend\Db\Select.php
  • Set a breakpoint on line 1379 where __toString() returns the SQL

Setting up a new development environment

Here are some of the trickiest things you need to do when setting up a development environment on a new computer.

  • Get CURL to work with Xampp
    • Edit C:\xampp\apache\conf\httpd.conf
    • Add this line: LoadFile "C:\xampp\php\libssh2.dll"
    • See this article
  • Install imagick (Image Magic):
    • See this article
    • Set Omeka ImageMagick DIrectory Path to C:\Program Files\ImageMagick-7.1.0-Q16-HDRI
  • Get GD to work by adding this line to php.ini:
    • extension=php_gd.dll
  • Install pdftotext.exe by copying the file from another machine into the c:\xampp.
  • Enable XDEBUG to work with PHPStorm:
    • Download and install xdebug from: and copy to xampp\php\ext.
    • Configure PHPStorm to use XDebug
    • Add the lines below to the end of php.ini:
zend_extension = C:\xampp\php\ext\php_xdebug-3.2.1-8.1-vs16-x86_64.dll

Restart Apache after making these kinds of changes.