====== 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 ==== In VuFind 2.4 or newer, 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 [[https://blog.library.villanova.edu/2020/04/23/vufind-moving-from-laminasconsole-to-symfonyconsole/|Moving from Laminas\Console to Symfony\Console]] for more history and details. ==== Using Legacy Wrapper Scripts ==== Prior to VuFind 2.4, the only way to access command line scripts was to run PHP scripts whose filenames corresponded with action names, and which were stored in directories corresponding with category names. These could be run like this: php $VUFIND_HOME/category/action.php [additional parameters] ===== 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 (in VuFind 2.4 or newer) 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 [[administration:performance#theme_compiler|theme compiler]] that was introduced in VuFind 4.1. ==== generate category ==== The generate category (introduced in release 2.4) contains code generation tools to help automate common VuFind customization tasks. It is documented in more detail on the [[development:code_generators|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 [[:indexing:oai-pmh|OAI-PMH harvesting]]. * merge-marc \\ Tool for merging individual MARC records together into a single collection (useful for improving import speed after harvesting records). ==== import category ==== The import category contains tools for loading records into VuFind's Solr index. Actions: * import-xsl \\ Tool for importing XML files into Solr using XSLT. * webcrawl \\ Tool for populating the website index when [[indexing:websites|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 [[development:architecture:customizing_vufind#modules|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. * normalize \\ Normalize (sort/deduplicate/tidy) a directory of language files. ==== scheduledsearch category ==== The scheduledsearch category is used for tasks related to VuFind's [[configuration:email_alerts|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: * cleanup_record_cache \\ Clean out the [[configuration:record_caching|record cache]], when used * commit \\ Commit the Solr index. * createHierarchyTrees \\ Populate the hierarchy cache when using [[indexing:hierarchies_and_collections|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 "[[development:npm|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_auth_hashes \\ Clean up expired authentication hashes (generated by Email [[configuration:authentication|authentication method]]). * expire_external_sessions \\ Clean up the external_sessions database table, when used. * 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.