Table of Contents
Command Line Utilities
VuFind® comes with several command-line utilities for manipulating its Solr index, maintaining its database, and performing other tasks without relying on the web interface.
Running the Tools
The command line tools are organized into categories and actions, similar to the web portion of the VuFind® application. (See the VuFindConsole module of the code for the implementation details). The specific categories and actions are documented below. Once you know which one you need, you can run it following these instructions.
Using the Index Script
The most consistent way to run command line tools is to run them through VuFind®'s framework directly using the application's index.php script.
The “PHP scripts in directory” approach to command line utilities was designed for backward compatibility with the structure of early VuFind® releases. However, the introduction of a formal framework in VuFind® 2 allowed a route-based approach where all commands can be invoked through a single endpoint – the application's index.php script.
php $VUFIND_HOME/public/index.php [category] [action] [additional parameters]
The code was implemented using the Zend\Console package until release 7.0, when that package was deprecated and had to be replaced with Symfony\Console. Only the internals changed, so the process of running the scripts remained the same – see the blog post Moving from Laminas\Console to Symfony\Console for more history and details.
Using Legacy Wrapper Scripts
For backward compatibility with early VuFind® releases, some command line scripts can also be run using PHP scripts whose filenames corresponded with action names, and which are stored in directories corresponding with category names. These can be run like this:
php $VUFIND_HOME/category/action.php [additional parameters]
Only older commands support this format, and its use is not recommended.
Troubleshooting
When running command line tools, it is important to make sure that you have appropriate VUFIND_HOME, VUFIND_LOCAL_DIR and VUFIND_LOCAL_MODULES environment variables set so that the correct code and configuration is loaded.
Many of VuFind®'s command-line tools make use of a disk-based cache to improve performance. This cache is most commonly found in the $VUFIND_LOCAL_DIR/cache/cli directory, unless you have custom configuration to use an alternate cache location. You should make sure that the user account running the tools has read and write permission for this cache directory.
Available Actions
A summary of all available actions can be viewed by running:
php $VUFIND_HOME/public/index.php
Most of these actions are also summarized below, grouped by category. However, in case this documentation falls out of date, the index.php output is always the most current way of finding all available tools.
compile category
The compile category contains the theme compiler.
generate category
The generate category contains code generation tools to help automate common VuFind® customization tasks. It is documented in more detail on the code generators page.
harvest category
The harvest category contains tools for collecting and managing records prior to import into VuFind®.
Actions:
- harvest_oai
Tool for OAI-PMH harvesting. - merge-marc
Tool for merging individual MARC records together into a single collection (which can improve import speed in some scenarios).
import category
The import category contains tools for loading records into VuFind®'s Solr index.
Actions:
- import-csv
Tool for importing data from CSV files. - import-xsl
Tool for importing XML files into Solr using XSLT. - webcrawl
Tool for populating the website index when indexing websites.
install category
Introduced in VuFind® 7.0, the install category integrates the formerly stand-alone install.php script with VuFind®'s core console infrastructure.
Actions:
- install
Run the install script to set up local modules, adjust Apache configuration, etc.
language category
The language category contains tools for managing VuFind®'s i18n language files.
Actions:
- addusingtemplate
Create a new string by combining one or more existing strings using a template. - copystring
Copy one language string to another in all of the language files. - delete
Delete a language string from all of the language files. - importlokalise
Used by the core project team to load translations from the Lokalise platform. - normalize
Normalize (sort/deduplicate/tidy) a directory of language files.
scheduledsearch category
The scheduledsearch category is used for tasks related to VuFind®'s Email Alerts functionality.
Actions:
- notify
Send out new notification emails, as needed.
util category
The util category is a catch-all for a variety of useful utilities.
Actions:
- browscap
Update the Browscap cache - cleanup_record_cache
Clean out the record cache, when used - commit
Commit the Solr index. - createHierarchyTrees
Populate the hierarchy cache when using hierarchies and collections. - cssBuilder
Compile LESS files into CSS within all themes. ( Deprecated as of VuFind® 8.0 and removed in VuFind® 9.0; use “npm run build:css” instead) - dedupe
Remove duplicate lines from a text file. - deletes
Remove all of the records in a specified MARC or text file from the Solr index. - expire_access_tokens
Clean up expired access tokens. - expire_auth_hashes
Clean up expired authentication hashes (generated by Email authentication method). - expire_external_sessions
Clean up the external_sessions database table, when used. - expire_login_tokens
Clean up expired login tokens. - expire_searches
Remove unwanted saved searches from the database. - expire_sessions
Remove old session data from the database. - index_reserves
Build a Solr index for course reserves. - lint_marc
Check a MARC file for errors. - optimize
Optimize the Solr index. - purge_cached_record
Purge a cached record and optionally a resource from the database. (This command was added in release 9.0). - scssBuilder
Compile SCSS files into CSS within all themes. - sitemap
Generate a sitemap for use with search engines. - suppressed
Delete all currently suppressed catalog records from the Solr index. - switch_db_hash
Change the password hashing algorithm in the database and configuration.