Developing for Aspen Discovery


Setting Up a Development Environment

Aspen uses a LAMP or WAMP stack to run. We have developers using both Windows and Mac OS X for development with success. If you plan to run on Windows, we recommend using a WAMP package like those created by Bitnami. When selecting an installer, select an installer that includes PHP 7.3 (we will update to PHP 8.0 later this year).

We recommend the following tools for Aspen development due to their ease of use and ability to debug code easily.

PhpStorm does have a small subscription fee, but we find it to be very worthwhile.

Once you have setup your LAMP/WAMP stack and your development tools, read on for instructions to install Aspen on Linux, Mac OSX, or Windows.

Note: after installing Bitnami for Windows, you will want to add the PHP runtime to your path to make running scripts from Aspen Discovery easier. After adding PHP to your path, you will need to restart Windows.

    Installing Aspen on Linux or MacOSX

    Installing Aspen on Linux or Mac OS X

    Aspen can run in production in a variety of environments. We recommend CentOS, RedHat, and Debian. Other environments may need code tweaks to run properly. These instructions are designed for CentOS 7. Other environments may require some changes to commands to run.

    Installation Steps

    1. Update the server
      sudo yum check-update

    2. Install git
      sudo yum -y install git

    3. Install the Aspen Discovery code (if you will be doing code development, you will want to create your own fork of the main git repository)
      cd /usr/local
      sudo git clone https://github.com/Aspen-Discovery/aspen-discovery.git
      Checkout the current branch:
      cd /usr/local/aspen-discovery/; sudo git pull origin 24.xx.yy

    4. Run the installer to setup the system files
      cd /usr/local/aspen-discovery/install/
      sudo ./installer.sh

      At the end of the installer, you will secure mariadb using a new password of your choosing
      When setting timezone use one of:
      America/New_York
      America/Chicago
      America/Denver
      America/Los_Angeles

    5. Restart the server to have SELinux changes take effect
      sudo reboot now

    6. The next step will be easier if you have connection information to your ILS. For Koha you will need ODBC and REST API connection information.

    7. Setup the site
      cd /usr/local/aspen-discovery/install/
      sudo php createSite.php

    8. Run database updates by logging in with the aspen_admin user you created while setting up the site and then going to: System Admin > DB Maintenance > Run

    Your site is now setup, but you will need to do some configuration of the site.

    1. Ensure all ports other than 80 and 443 (and 25 if needed for SSH access) are firewalled so they cannot be accessed by the world.
    2. Add the server external IP to the list of IPs as 'Allow API Access'
    3. Setup Initial Library and Location information
    4. Setup Account Profile (this is setup during the install process if you are using Koha)
    5. Setup Indexing Profile
    6. Setup Translation Maps
    7. Setup recaptcha
    8. Run a new index
    9. Setup cron (not needed for development installs)
    10. Setup SSL (not needed for development installs)
    Installing Aspen on Windows

    Installing Aspen on Windows

    Aspen can run for development on Windows. We do not recommend using Windows for production environments. Prior to starting these steps you should setup your environment.

    For Windows, we also recommend using GitHub Desktop to make working with git easier.
    Cygwin will add common Linux commands to your Windows shell and is recommended for Aspen development.

    Installation Steps

    1. Make a fork of the main Aspen Discovery Code from https://github.com/Aspen-Discovery/aspen-discovery.

    2. Install the Aspen Discovery code by cloning the repository to c:\web\.

    3. The next step will be easier if you have connection information to your ILS. For Koha you will need ODBC and REST API connection information.

    4. Setup the site
      cd c:\web\aspen-discovery\install\
      php createSite.php

    5. Run database updates by logging in with the aspen_admin user you created while setting up the site and then going to: System Admin > DB Maintenance > Run

    Your site is now setup, but you will need to do some configuration of the site.

    1. Ensure all ports other than 80 and 443 (and 25 if needed for SSH access) are firewalled so they cannot be accessed by the world.
    2. Add the hostname you want to use for aspen to c:\Windows\System32\drivers\etc\hosts
    3. Add the server external IP to the list of IPs as 'Allow API Access' (not needed for development installs)
    4. Setup Initial Library and Location information
    5. Setup Account Profile (this is setup during the install process if you are using Koha)
    6. Setup Indexing Profile
    7. Setup Translation Maps
    8. Setup recaptcha
    9. Run a new index
    10. Setup cron (not needed for development installs)
    11. Setup SSL (not needed for development installs)
    PHP Coding Guidelines

    PHP Guidelines

    Settings for PHPStorm are stored in git in the root directory as PHPStormCodeStyle.xml and can be imported into PHPStorm to automatically configure your editor.

    • Code should use tabs for indenting, not spaces.
    • Hard wrap after 500, but try to keep comments formatted so they are readable in the editor with soft wrapping as needed.
    • Function names should use camel case.
    • Property names should use camel case.
    • Table names in the database should be all lower case with underscores separating words.
    • Arrays should be constructed using square brackets rather than array(...)
    • Opening brackets for functions should be on the same line as the function name with a space after the function parameters.
    • Opening brackets for class declartions should be on the same line as the class name.
    • If there are empty functions / methods, place the braces on one line
    • else should be on its own line
    • No single line if statements without braces
    • for & foreach statements should use braces
    • while statments should use braces

    Developer Bootcamp